mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-23 16:19:35 -05:00
cleanup filter escaping
This commit is contained in:
parent
6ab23ef926
commit
f86543c770
4 changed files with 8 additions and 49 deletions
|
|
@ -366,10 +366,10 @@ ldap_search_s(
|
||||||
}
|
}
|
||||||
|
|
||||||
static char escape[128] = {
|
static char escape[128] = {
|
||||||
1, 0, 0, 0, 0, 0, 0, 0,
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
1, 1, 1, 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, 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) ])
|
#define NEEDFLTESCAPE(c) ((c) & 0x80 || escape[ (unsigned)(c) ])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1912,7 +1912,7 @@ backsql_search( Operation *op, SlapReply *rs )
|
||||||
Debug( LDAP_DEBUG_TRACE, "==>backsql_search(): "
|
Debug( LDAP_DEBUG_TRACE, "==>backsql_search(): "
|
||||||
"base=\"%s\", filter=\"%s\", scope=%d,",
|
"base=\"%s\", filter=\"%s\", scope=%d,",
|
||||||
op->o_req_ndn.bv_val,
|
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 );
|
op->ors_scope );
|
||||||
Debug( LDAP_DEBUG_TRACE, " deref=%d, attrsonly=%d, "
|
Debug( LDAP_DEBUG_TRACE, " deref=%d, attrsonly=%d, "
|
||||||
"attributes to load: %s\n",
|
"attributes to load: %s\n",
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,6 @@ static int get_ssa(
|
||||||
SubstringsAssertion **s,
|
SubstringsAssertion **s,
|
||||||
const char **text );
|
const char **text );
|
||||||
|
|
||||||
static int filter_escape_value_x(
|
|
||||||
struct berval *in,
|
|
||||||
struct berval *out,
|
|
||||||
void *ctx );
|
|
||||||
|
|
||||||
static void simple_vrFilter2bv(
|
static void simple_vrFilter2bv(
|
||||||
Operation *op,
|
Operation *op,
|
||||||
ValuesReturnFilter *f,
|
ValuesReturnFilter *f,
|
||||||
|
|
@ -782,42 +777,6 @@ filter2bv( Filter *f, struct berval *fstr )
|
||||||
filter2bv_x( &op, f, 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
|
static int
|
||||||
get_simple_vrFilter(
|
get_simple_vrFilter(
|
||||||
Operation *op,
|
Operation *op,
|
||||||
|
|
|
||||||
|
|
@ -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 (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_has_subordinates LDAP_P(( Filter *filter ));
|
||||||
LDAP_SLAPD_F (int) filter_escape_value LDAP_P(( struct berval *in,
|
#define filter_escape_value( in, out ) ldap_bv2escaped_filter_value_x( (in), (out), 0, NULL )
|
||||||
struct berval *out ));
|
#define filter_escape_value_x( in, out, ctx ) ldap_bv2escaped_filter_value_x( (in), (out), 0, ctx )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* filterentry.c
|
* filterentry.c
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue