cleanup filter escaping

This commit is contained in:
Pierangelo Masarati 2005-11-25 12:16:27 +00:00
parent 6ab23ef926
commit f86543c770
4 changed files with 8 additions and 49 deletions

View File

@ -366,10 +366,10 @@ ldap_search_s(
}
static char escape[128] = {
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 0, 0, 0, 0, 0,
@ -384,7 +384,7 @@ static char escape[128] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 1
};
#define NEEDFLTESCAPE(c) ((c) & 0x80 || escape[ (unsigned)(c) ])

View File

@ -1912,7 +1912,7 @@ backsql_search( Operation *op, SlapReply *rs )
Debug( LDAP_DEBUG_TRACE, "==>backsql_search(): "
"base=\"%s\", filter=\"%s\", scope=%d,",
op->o_req_ndn.bv_val,
op->ors_filterstr.bv_val ? op->ors_filterstr.bv_val : "(no filter)",
op->ors_filterstr.bv_val,
op->ors_scope );
Debug( LDAP_DEBUG_TRACE, " deref=%d, attrsonly=%d, "
"attributes to load: %s\n",

View File

@ -45,11 +45,6 @@ static int get_ssa(
SubstringsAssertion **s,
const char **text );
static int filter_escape_value_x(
struct berval *in,
struct berval *out,
void *ctx );
static void simple_vrFilter2bv(
Operation *op,
ValuesReturnFilter *f,
@ -782,42 +777,6 @@ filter2bv( Filter *f, struct berval *fstr )
filter2bv_x( &op, f, fstr );
}
static int
filter_escape_value_x(
struct berval *in,
struct berval *out,
void *ctx )
{
ber_len_t i;
assert( in != NULL );
assert( out != NULL );
i = in->bv_len * 3 + 1;
out->bv_val = ctx ? slap_sl_malloc( i, ctx ) : ch_malloc( i );
out->bv_len = 0;
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] );
} else {
out->bv_val[out->bv_len++] = in->bv_val[i];
}
}
out->bv_val[out->bv_len] = '\0';
return LDAP_SUCCESS;
}
int
filter_escape_value(
struct berval *in,
struct berval *out )
{
return filter_escape_value_x( in, out, NULL );
}
static int
get_simple_vrFilter(
Operation *op,

View File

@ -913,8 +913,8 @@ LDAP_SLAPD_F (void) vrFilter_free LDAP_P(( Operation *op, ValuesReturnFilter *f
LDAP_SLAPD_F (void) vrFilter2bv LDAP_P(( Operation *op, ValuesReturnFilter *f, struct berval *fstr ));
LDAP_SLAPD_F (int) filter_has_subordinates LDAP_P(( Filter *filter ));
LDAP_SLAPD_F (int) filter_escape_value LDAP_P(( struct berval *in,
struct berval *out ));
#define filter_escape_value( in, out ) ldap_bv2escaped_filter_value_x( (in), (out), 0, NULL )
#define filter_escape_value_x( in, out, ctx ) ldap_bv2escaped_filter_value_x( (in), (out), 0, ctx )
/*
* filterentry.c