[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: ldap_explode_dn corrupts UTF-8 encoding (ITS#1890)



ps@psncc.at writes: 

> Well, the code fragment that broke is: 
> 
> 	    char **exploded_dn, *dn;
> 	    LDAP *ld;
>             LDAPMessage *e; 
> 
> 	    [snip] 
> 
> 	    dn = ldap_get_dn(ld, e);
> 	    /* explode DN */
> 	    exploded_dn = ldap_explode_dn(dn, FALSE); 
> 
> 
> Which is exactly what the man page for ldap_explode_dn suggests. And it is
> straightforward too.

I see a  /* deprecated */ 

LDAP_F( char ** )
ldap_explode_dn LDAP_P(( /* deprecated */
       LDAP_CONST char *dn,
       int notypes )); 

in ldap.h; this is one of the reasons. 

> 
>> They are; but they're represented in another form that is allowed
>> for DNs; it depends on whether you like it or not.  I understand
> 
> I just think it is not good to break existing functionality.

Agree, but up to a point: deprecation and obsoletion
at some point of standard track (and software) lifetime
may occur. 

>> You may use: 
>>
>> 	int i;
>> 	LDAPDN *dn;
>> 	char **v = 0; 
>>
>> 	ldap_str2dn( string, &dn, LDAP_DN_FORMAT_LDAP);
>> 	for ( i = 0; dn[i]; i++ ) {
>> 		v = realloc( v, i + 2 );
>> 		ldap_rdn2str( dn[ 0 ][ i ], &v[ i ],
>> 			LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY );
>> 	} 
>>
> 
> That code looks a lot more complex and incomprehesible than the
> straightforward code fragment above... :-(

well, it's not so incomprehensible: you get a dn, and then
rewrite each part in a readable form, choosing whatever
format you need.  Or you use ldap_explode_dn, accepting
the format that's given back. 

> It is mostly a matter of breaking things that used to work.

I have no problems in letting ldap_explode_dn/rdn return
a "pretty" (UTF-8) form of the dn: it's not a big deal; however
I'd like to see some consensus on that, which is difficult
to gather on obsoleted function calls: everybody would like
to keep them as they were, regardless of incompatibilities
or problems that might arise if fancy formats are used. 

Pierangelo. 

Dr. Pierangelo Masarati               | voice: +39 02 2399 8309
Dip. Ing. Aerospaziale                | fax:   +39 02 2399 8334
Politecnico di Milano                 | mailto:pierangelo.masarati@polimi.it
via La Masa 34, 20156 Milano, Italy   | http://www.aero.polimi.it/~masarati