--- servers/slapd/filter.c 2001/06/22 23:59:28 1.13.4.8 +++ servers/slapd/filter.c 2000/07/02 15:14:37 1.51 @@ -1,5 +1,5 @@ /* filter.c - routines for parsing and dealing with filters */ -/* $OpenLDAP$ */ +/* $OpenLDAP: pkg/ldap/servers/slapd/filter.c,v 1.50 2000/07/02 05:18:55 mrv Exp $ */ /* * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -257,7 +257,7 @@ get_filter( case LDAP_FILTER_EXT: /* not yet implemented */ Debug( LDAP_DEBUG_ANY, "extensible match not yet implemented.\n", - 0, 0, 0 ); + f->f_choice, 0, 0 ); (void) ber_skip_tag( ber, &len ); f->f_choice = SLAPD_FILTER_COMPUTED; f->f_result = SLAPD_COMPARE_UNDEFINED; @@ -265,7 +265,7 @@ get_filter( break; default: - (void) ber_scanf( ber, "x" ); /* skip the element */ + (void) ber_skip_tag( ber, &len ); Debug( LDAP_DEBUG_ANY, "get_filter: unknown filter type=%lu\n", f->f_choice, 0, 0 ); f->f_choice = SLAPD_FILTER_COMPUTED; @@ -443,10 +443,7 @@ get_substring_filter( switch ( tag ) { case LDAP_SUBSTRING_INITIAL: Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); - if ( f->f_sub_initial != NULL - || f->f_sub_any != NULL - || f->f_sub_final != NULL ) - { + if ( f->f_sub_initial != NULL ) { ber_bvfree( value ); goto return_error; } @@ -464,12 +461,6 @@ get_substring_filter( case LDAP_SUBSTRING_ANY: Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); - - if ( f->f_sub_final != NULL ) { - ber_bvfree( value ); - goto return_error; - } - if( ber_bvecadd( &f->f_sub_any, value ) < 0 ) { ber_bvfree( value ); goto return_error; @@ -487,12 +478,10 @@ get_substring_filter( case LDAP_SUBSTRING_FINAL: Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); - if ( f->f_sub_final != NULL ) { ber_bvfree( value ); goto return_error; } - f->f_sub_final = value; if( fstr ) { @@ -710,11 +699,18 @@ int filter_escape_value( out->bv_val = (char *) ch_malloc( ( in->bv_len * 3 ) + 1 ); out->bv_len = 0; +#undef NIBBLE +#undef ESCAPE_LO +#undef ESCAPE_HI +#define NIBBLE(c) ((c)&0x0f) +#define ESCAPE_LO(c) ( NIBBLE(c) + ( NIBBLE(c) < 10 ? '0' : 'A' - 10 ) ) +#define ESCAPE_HI(c) ( ESCAPE_LO((c)>>4) ) + for( i=0; i < in->bv_len ; i++ ) { if( FILTER_ESCAPE(in->bv_val[i]) ) { - out->bv_val[out->bv_len++] = SLAP_ESCAPE_CHAR; - out->bv_val[out->bv_len++] = SLAP_ESCAPE_HI( in->bv_val[i] ); - out->bv_val[out->bv_len++] = SLAP_ESCAPE_LO( in->bv_val[i] ); + out->bv_val[out->bv_len++] = '\\'; + out->bv_val[out->bv_len++] = ESCAPE_HI( in->bv_val[i] ); + out->bv_val[out->bv_len++] = ESCAPE_LO( in->bv_val[i] ); } else { out->bv_val[out->bv_len++] = in->bv_val[i]; } @@ -723,3 +719,5 @@ int filter_escape_value( out->bv_val[out->bv_len] = '\0'; return LDAP_SUCCESS; } + +