]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/filter.c
Fix extensible filters
[openldap] / libraries / libldap / filter.c
index 960327de282f4950b933d42ae155c150b22cdd3e..4f475830ad7c995d1c743ca9d770e39fd5313826 100644 (file)
@@ -183,11 +183,11 @@ ldap_pvt_find_wildcard( const char *s )
 
                case '\\':
                        if( s[1] == '\0' ) return NULL;
+
                        if( LDAP_HEX( s[1] ) && LDAP_HEX( s[2] ) ) {
                                s+=2;
-                       }
 
-                       switch( s[1] ) {
+                       } else switch( s[1] ) {
                        default:
                                return NULL;
 
@@ -201,7 +201,7 @@ ldap_pvt_find_wildcard( const char *s )
                }
        }
 
-       return s;
+       return (char *) s;
 }
 
 /* unescape filter value */
@@ -332,7 +332,7 @@ ldap_int_put_filter( BerElement *ber, char *str )
         * Note: tags in a choice are always explicit
         */
 
-       Debug( LDAP_DEBUG_TRACE, "put_filter \"%s\"\n", str, 0, 0 );
+       Debug( LDAP_DEBUG_TRACE, "put_filter: \"%s\"\n", str, 0, 0 );
 
        parens = 0;
        while ( *str ) {
@@ -491,7 +491,7 @@ put_simple_filter(
        ber_tag_t       ftype;
        int             rc = -1;
 
-       Debug( LDAP_DEBUG_TRACE, "put_simple_filter \"%s\"\n",
+       Debug( LDAP_DEBUG_TRACE, "put_simple_filter: \"%s\"\n",
                str, 0, 0 );
 
        str = LDAP_STRDUP( str );
@@ -591,18 +591,23 @@ put_simple_filter(
                        if( rc != -1 && *str != '\0' ) {
                                rc = ber_printf( ber, "ts", LDAP_FILTER_EXT_TYPE, str );
                        }
-
                        if( rc != -1 ) {
                                ber_slen_t len = ldap_pvt_filter_value_unescape( value );
 
                                if( len >= 0 ) {
-                                       rc = ber_printf( ber, /*"{"*/ "totbN}",
-                                               LDAP_FILTER_EXT_VALUE, value, len,
-                                               LDAP_FILTER_EXT_DNATTRS, dn != NULL);
+                                       rc = ber_printf( ber, "to",
+                                               LDAP_FILTER_EXT_VALUE, value, len );
                                } else {
                                        rc = -1;
                                }
                        }
+                       if( rc != -1 && dn ) {
+                               rc = ber_printf( ber, "tb",
+                                       LDAP_FILTER_EXT_DNATTRS, (ber_int_t) 1 );
+                       }
+                       if( rc != -1 ) { 
+                               rc = ber_printf( ber, /*"{"*/ "N}" );
+                       }
                }
                goto done;