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.66 2005/01/24 16:17:52 mast Exp $ + // $Id: client.pike,v 1.67 2005/01/26 15:06:44 mast 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:363:    //! @expr{"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.66 $"/" ")[1] ]); +  info = ([ "code_revision" : ("$Revision: 1.67 $"/" ")[1] ]);       if(!url || !sizeof(url))    url = LDAP_DEFAULT_URL;       lauth = parse_url(url);       if(!stringp(lauth->scheme) ||    ((lauth->scheme != "ldap")   #if constant(SSL.Cipher.CipherAlgorithm)    && (lauth->scheme != "ldaps")
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:818:       // Afaict from the RFCs no insignificant whitespace is allowed in    // query filters, but the old parser and other query tools (at    // least LDP in Windows XP) seem to accept it anyway. This makes    // it somewhat unclear whether whitespace around values should be    // significant or not. This parser always treat whitespace as    // significant there (and inside operators) but not anywhere else.    // /mast   #define WS "%*[ \t\n\r]"    -  string|int read_filter_value() +  string read_filter_value()    // Reads a filter value encoded according to section 4 in RFC 2254    // and section 3 in the older RFC 1960.    {    string res = ""; -  +  //werror ("read_filter_value %O\n", filter);    while (1) {    sscanf (filter, "%[^()*\\]%s", string val, filter);    res += val;    if (filter == "" || (<'(', ')', '*'>)[filter[0]]) break; -  if (sscanf (filter, "\\%2x%s", int chr, filter) == 2) -  // RFC 2254. -  res += sprintf ("%c", chr); -  else if ((<"*", "(", ")">)[val = filter[1..1]]) { +  // filter[0] == '\\' now. +  if (sscanf (filter, "\\%1x%1x%s", int high, int low, filter) == 3) +  // RFC 2254. (Use two %1x to force reading of exactly two +  // hex digits; something like %2.2x is currently not +  // supported.) +  res += sprintf ("%c", (high << 4) + low); +  else {    // RFC 1960. Note that this RFC doesn't define a consistent    // quoting since a "\" shouldn't be quoted. That means it    // isn't possible to specify a value ending with "\". -  +  if (sscanf (filter, "\\%1[*()]%s", val, filter) == 2)    res += val; -  +  else { +  res += filter[..1];    filter = filter[2..];    } -  else -  FILTER_PARSE_ERR ("Invalid quoting in value.\n"); +     } -  +  } +  //werror ("read_filter_value => %O (rest: %O)\n", res, filter);    return res;    };       object|int make_filter_recur()    {    object res;       //werror ("make_filter_recur %O\n", filter);       // Legacy error reporting: If there's a syntax error then -1 is
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:926:    filter = filter[1..];    }    else {    // Same kind of slightly lax check on the matching rule    // identifier here as on the attribute above.    if (sscanf (filter, "%[-A-Za-z0-9.]"WS":=%s", matching_rule, filter) != 3 ||    matching_rule == "")    FILTER_PARSE_ERR ("Error parsing matching rule identifier.\n");    }    -  string|int val = read_filter_value(); -  if (intp (val)) return 0; +  string val = read_filter_value();       res = ASN1_CONTEXT_SEQUENCE ( // 'extensibleMatch'    9, ((matching_rule ?    ({ASN1_CONTEXT_OCTET_STRING (1, matching_rule)}) : ({})) +    (attr != "" ?    ({ASN1_CONTEXT_OCTET_STRING (2, attr)}) : ({})) +    ({ASN1_CONTEXT_OCTET_STRING (3, val),    ASN1_CONTEXT_BOOLEAN (4, dn_attrs)})));    }       else {    if (attr == "") FILTER_PARSE_ERR ("Expected attribute.\n");    -  string|int|object val = read_filter_value(); -  if (intp (val)) return 0; +  string|object val = read_filter_value();       if (op == "=" && has_prefix (filter, "*")) {    array(string) parts = ({val});    do {    filter = filter[1..];    val = read_filter_value(); -  if (intp (val)) return 0; +     parts += ({val});    } while (has_prefix (filter, "*"));       array(object) subs = sizeof (parts[0]) ?    ({ASN1_CONTEXT_OCTET_STRING (0, parts[0])}) : ({});    foreach (parts[1..sizeof (parts) - 2], string middle)    subs += ({ASN1_CONTEXT_OCTET_STRING (1, middle)});    if (sizeof (parts) > 1 && sizeof (parts[-1]))    subs += ({ASN1_CONTEXT_OCTET_STRING (2, parts[-1])});