From: Pierangelo Masarati Date: Wed, 5 Dec 2001 16:34:51 +0000 (+0000) Subject: a gross attempt to implement a schema-aware normalization X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~767 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=335a8bd0ad394ac6ef6b1984dca42b0feea53227;p=openldap a gross attempt to implement a schema-aware normalization --- diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index c3d0fd50ee..c1cc2cfa26 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -254,20 +254,84 @@ dnNormalize( if ( val->bv_len != 0 ) { LDAPDN *dn = NULL; char *dn_out = NULL; - int rc; + int rc, iRDN; rc = ldap_str2dn( val->bv_val, &dn, LDAP_DN_FORMAT_LDAPV3 ); if ( rc != LDAP_SUCCESS ) { return( LDAP_INVALID_SYNTAX ); } +#if 0 + /* + * Add schema-aware normalization stuff + */ + for ( iRDN = 0; dn[ iRDN ]; iRDN++ ) { + LDAPRDN *rdn = dn[ iRDN ][ 0 ]; + int iAVA; + + for ( iAVA = 0; rdn[ iAVA ]; iAVA++ ) { + LDAPAVA *ava = rdn[ iAVA ][ 0 ]; + AttributeDescription *ad = NULL; + const char *text = NULL; + slap_syntax_transform_func *nf = NULL; + struct berval *bv = NULL; + + rc = slap_bv2ad( ava->la_attr, &ad, &text ); + if ( rc != LDAP_SUCCESS ) { + goto error_return; + } + + /* + * FIXME: is this required? + */ + if ( isalpha( ava->la_attr->bv_val[0] ) ) { + (void) ldap_pvt_str2upper( ava->la_attr->bv_val ); + } + + /* + * FIXME: What is this intended for? + */ + nf = ad->ad_type->sat_syntax->ssyn_normalize; + if ( !nf ) { + break; + } + + rc = ( *nf )( ad->ad_type->sat_syntax, + ava->la_value, &bv ); + + if ( rc != LDAP_SUCCESS ) { + goto error_return; + } + + /* + * FIXME: shouldn't this happen inside + * ssyn_normalize if the syntax is case + * insensitive? + */ + if ( !( ava->la_flags & LDAP_AVA_BINARY ) ) { + struct berval *s = bv; + + bv = ber_bvstr( UTF8normalize( bv, + UTF8_CASEFOLD ) ); + ber_bvfree( s ); + } + + ber_bvfree( ava->la_value ); + ava->la_value = bv; + } + } +#endif + rc = ldap_dn2str( dn, &dn_out, LDAP_DN_FORMAT_LDAPV3 ); - ldapava_free_dn( dn ); if ( rc != LDAP_SUCCESS ) { +error_return:; + ldapava_free_dn( dn ); return( LDAP_INVALID_SYNTAX ); } + ldapava_free_dn( dn ); + out = ber_bvstr( dn_out ); } else {