]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/str2filter.c
Fix aci link error.
[openldap] / servers / slapd / str2filter.c
index ebc26fe4995771aeb5caaf7642d706c87b6eb526..f21ffd2d7fb13a47883c107b1ec0cb281fdaa894 100644 (file)
@@ -145,6 +145,8 @@ str2simple( const char *str )
        Filter          *f;
        char            *s;
        char            *value, savechar;
+       int                     rc;
+       const char              *text;
 
        Debug( LDAP_DEBUG_FILTER, "str2simple \"%s\"\n", str, 0, 0 );
 
@@ -152,7 +154,8 @@ str2simple( const char *str )
                return( NULL );
        }
        value = &s[1];
-       *s-- = '\0';
+
+       *s-- = '\0';    /* we shouldn't be mucking with str */
        savechar = *s;
 
        f = (Filter *) ch_calloc( 1, sizeof(Filter) );
@@ -173,6 +176,7 @@ str2simple( const char *str )
        case ':':
                f->f_choice = LDAP_FILTER_EXT;
                *s = '\0';
+               return NULL;
                break;
 
        default:
@@ -182,8 +186,13 @@ str2simple( const char *str )
                        f->f_choice = LDAP_FILTER_PRESENT;
                } else {
                        f->f_choice = LDAP_FILTER_SUBSTRINGS;
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
-                       f->f_sub_type = ch_strdup( str );
+                       f->f_sub = ch_calloc( 1, sizeof( SubstringsAssertion ) );
+                       rc = slap_str2ad( str, &f->f_sub_desc, &text );
+                       if( rc != LDAP_SUCCESS ) {
+                               filter_free( f );
+                               *(value-1) = '=';
+                               return NULL;
+                       }
                        if ( str2subvals( value, f ) != 0 ) {
                                filter_free( f );
                                *(value-1) = '=';
@@ -191,24 +200,37 @@ str2simple( const char *str )
                        }
                        *(value-1) = '=';
                        return( f );
-#endif
                }
                break;
        }
 
-#ifndef SLAPD_SCHEMA_NOT_COMPAT
        if ( f->f_choice == LDAP_FILTER_PRESENT ) {
-               f->f_type = ch_strdup( str );
+               rc = slap_str2ad( str, &f->f_desc, &text );
+               if( rc != LDAP_SUCCESS ) {
+                       filter_free( f );
+                       *(value-1) = '=';
+                       return NULL;
+               }
        } else {
-               f->f_avtype = ch_strdup( str );
-               f->f_avvalue.bv_val = ch_strdup( value );
-               ldap_pvt_filter_value_unescape( f->f_avvalue.bv_val );
-               f->f_avvalue.bv_len = strlen( value );
+               char *tmp;
+
+               f->f_ava = ch_calloc( 1, sizeof( AttributeAssertion ) );
+               f->f_av_desc = NULL;
+               rc = slap_str2ad( str, &f->f_av_desc, &text );
+               if( rc != LDAP_SUCCESS ) {
+                       filter_free( f );
+                       *(value-1) = '=';
+                       return NULL;
+               }
+
+               tmp = ch_strdup( value );
+               ldap_pvt_filter_value_unescape( tmp );
+               f->f_av_value = ber_bvstr( tmp );
        }
 
        *s = savechar;
        *(value-1) = '=';
-#endif
+
        return( f );
 }