Commit ef607e65 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

first round at replacing UTF8normalize with UTF8bvnormalize

parent 217103b1
...@@ -144,6 +144,11 @@ LDAP_LUNICODE_F(char *) UTF8normalize( ...@@ -144,6 +144,11 @@ LDAP_LUNICODE_F(char *) UTF8normalize(
struct berval *, struct berval *,
unsigned ); unsigned );
LDAP_LUNICODE_F(struct berval *) UTF8bvnormalize(
struct berval *,
struct berval *,
unsigned );
LDAP_LUNICODE_F(int) UTF8normcmp( LDAP_LUNICODE_F(int) UTF8normcmp(
const char *, const char *,
const char *, const char *,
......
...@@ -298,9 +298,10 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags ) ...@@ -298,9 +298,10 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
if( mr && ( mr->smr_usage & SLAP_MR_DN_FOLD ) ) { if( mr && ( mr->smr_usage & SLAP_MR_DN_FOLD ) ) {
char *s = bv.bv_val; char *s = bv.bv_val;
ber_str2bv( UTF8normalize( bv.bv_val ? &bv if ( UTF8bvnormalize( &bv, &bv,
: &ava->la_value, LDAP_UTF8_CASEFOLD ), LDAP_UTF8_CASEFOLD ) == NULL ) {
0, 0, &bv ); return LDAP_INVALID_SYNTAX;
}
free( s ); free( s );
} }
......
...@@ -609,8 +609,7 @@ UTF8SubstringsassertionNormalize( ...@@ -609,8 +609,7 @@ UTF8SubstringsassertionNormalize(
} }
if( sa->sa_initial.bv_val != NULL ) { if( sa->sa_initial.bv_val != NULL ) {
ber_str2bv( UTF8normalize( &sa->sa_initial, casefold ), 0, UTF8bvnormalize( &sa->sa_initial, &nsa->sa_initial, casefold );
0, &nsa->sa_initial );
if( nsa->sa_initial.bv_val == NULL ) { if( nsa->sa_initial.bv_val == NULL ) {
goto err; goto err;
} }
...@@ -622,8 +621,8 @@ UTF8SubstringsassertionNormalize( ...@@ -622,8 +621,8 @@ UTF8SubstringsassertionNormalize(
} }
nsa->sa_any = (struct berval *)ch_malloc( (i + 1) * sizeof(struct berval) ); nsa->sa_any = (struct berval *)ch_malloc( (i + 1) * sizeof(struct berval) );
for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) { for( i=0; sa->sa_any[i].bv_val != NULL; i++ ) {
ber_str2bv( UTF8normalize( &sa->sa_any[i], casefold ), UTF8bvnormalize( &sa->sa_any[i], &nsa->sa_any[i],
0, 0, &nsa->sa_any[i] ); casefold );
if( nsa->sa_any[i].bv_val == NULL ) { if( nsa->sa_any[i].bv_val == NULL ) {
goto err; goto err;
} }
...@@ -632,8 +631,7 @@ UTF8SubstringsassertionNormalize( ...@@ -632,8 +631,7 @@ UTF8SubstringsassertionNormalize(
} }
if( sa->sa_final.bv_val != NULL ) { if( sa->sa_final.bv_val != NULL ) {
ber_str2bv( UTF8normalize( &sa->sa_final, casefold ), 0, UTF8bvnormalize( &sa->sa_final, &nsa->sa_final, casefold );
0, &nsa->sa_final );
if( nsa->sa_final.bv_val == NULL ) { if( nsa->sa_final.bv_val == NULL ) {
goto err; goto err;
} }
...@@ -1045,7 +1043,7 @@ caseExactIgnoreSubstringsMatch( ...@@ -1045,7 +1043,7 @@ caseExactIgnoreSubstringsMatch(
{ {
int match = 0; int match = 0;
SubstringsAssertion *sub = NULL; SubstringsAssertion *sub = NULL;
struct berval left; struct berval left = { 0, NULL };
int i; int i;
ber_len_t inlen=0; ber_len_t inlen=0;
char *nav; char *nav;
...@@ -1054,13 +1052,11 @@ caseExactIgnoreSubstringsMatch( ...@@ -1054,13 +1052,11 @@ caseExactIgnoreSubstringsMatch(
casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID ) casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD; ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
nav = UTF8normalize( value, casefold ); if ( UTF8bvnormalize( value, &left, casefold ) == NULL ) {
if( nav == NULL ) {
match = 1; match = 1;
goto done; goto done;
} }
left.bv_val = nav; nav = left.bv_val;
left.bv_len = strlen( nav );
sub = UTF8SubstringsassertionNormalize( assertedValue, casefold ); sub = UTF8SubstringsassertionNormalize( assertedValue, casefold );
if( sub == NULL ) { if( sub == NULL ) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment