pike.git / lib / modules / Protocols.pmod / LDAP.pmod / client.pike

version» Context lines:

pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1:   #pike __REAL_VERSION__      // LDAP client protocol implementation for Pike.   // - // $Id: client.pike,v 1.35 2004/10/13 15:45:28 wellhard Exp $ + // $Id: client.pike,v 1.36 2005/01/24 10:42:54 wellhard Exp $   //   // Honza Petrous, hop@unibase.cz   //   // ----------------------------------------------------------------------   //   // History:   //   // v0.0 1998-05-25 Starting up!   // v1.0 1998-06-21 Core functions (open, bind, unbind, delete, add,   // compare, search), only V2 operations,
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:361:    //! @tt{"ldap://hostname/basedn?attrlist?scope?ext"@}    //!    //! @param context    //! TLS context of connection    //!    //! @seealso    //! @[LDAP.client.bind], @[LDAP.client.search]    void create(string|void url, object|void context)    {    -  info = ([ "code_revision" : ("$Revision: 1.35 $"/" ")[1] ]); +  info = ([ "code_revision" : ("$Revision: 1.36 $"/" ")[1] ]);       if(!url || !sizeof(url))    url = LDAP_DEFAULT_URL;       lauth = parse_url(url);       if(!stringp(lauth->scheme) ||    ((lauth->scheme != "ldap")   #if constant(SSL.sslfile)    && (lauth->scheme != "ldaps")
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:699:    THROW(({error_string()+"\n",backtrace()}));    return(-ldap_errno);    }       last_rv = result(({raw}));    DWRITE_HI(sprintf("client.ADD: %s\n", last_rv->error_string()));    return seterr (last_rv->error_number());       } // add    +  static string unescape_filter_value (string val) +  // Decodes escapes in val according to section 4 in RFC 2254 and +  // section 3 in the older RFC 1960. +  { +  string res = ""; +  while (sscanf (val, "%s\\%s", string pre, val) == 2) { +  res += pre; +  if (sscanf (val, "%2x%s", int chr, val) == 2) +  res += sprintf ("%c", chr); +  else { +  res += val[..0]; +  val = val[1..]; +  } +  } +  return res + val; +  } +     private static array(string) filter_get_sub1expr(string fstr) {    // returns one-level brackets enclosed expressions       array(string) rvarr = ({});    int leftflg = 0, nskip = 0;       for(int ix=0; ix<sizeof(fstr); ix++)    if((fstr[ix] == '(') && (!ix || (fstr[ix-1] != '\\'))) {    leftflg = ix+1;    while(++ix < sizeof(fstr)) {
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:777:    ahlp += ({ filtval[cnt] });    } else    ahlp = ({ filtval[cnt] });    } // for       // filter elements processing (left, center & right)    ix = sizeof(ahlp);    for (int cnt = 0; cnt < ix; cnt++)    if(!cnt) { // leftmost element    if(sizeof(ahlp[0])) -  oarr = ({ASN1_CONTEXT_OCTET_STRING(0, ahlp[0])}); +  oarr = ({ASN1_CONTEXT_OCTET_STRING( +  0, unescape_filter_value (ahlp[0]))});    } else    if(cnt == ix-1) { // rightmost element    if(sizeof(ahlp[ix-1])) -  oarr += ({ASN1_CONTEXT_OCTET_STRING(2, ahlp[ix-1])}); +  oarr += ({ASN1_CONTEXT_OCTET_STRING( +  2, unescape_filter_value (ahlp[ix-1]))});    } else { // inside element    if(sizeof(ahlp[cnt])) -  oarr += ({ASN1_CONTEXT_OCTET_STRING(1, ahlp[cnt])}); +  oarr += ({ASN1_CONTEXT_OCTET_STRING( +  1, unescape_filter_value (ahlp[cnt]))});    }    // for       DWRITE(sprintf("client.make_simple_filter: substring: [%s]:\n%O\n", filter, ahlp));    return(ASN1_CONTEXT_SEQUENCE(4,    ({Standards.ASN1.Types.asn1_octet_string(filter[..(op-1)]),    Standards.ASN1.Types.asn1_sequence(oarr)    })));    } else { // equal    DWRITE("client.make_simple_filter: [=]\n");    return(ASN1_CONTEXT_SEQUENCE(3,    ({Standards.ASN1.Types.asn1_octet_string(filter[..(op-1)]), -  Standards.ASN1.Types.asn1_octet_string(filter[(op+1)..]) +  Standards.ASN1.Types.asn1_octet_string( +  unescape_filter_value (filter[(op+1)..]))    })));    }    } // if equal,substring    // present    DWRITE("client.make_simple_filter: [present]\n");    return(ASN1_CONTEXT_OCTET_STRING(7, filter));   }          /*private*/ object|int make_filter(string filter) {