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

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

ps@psncc.at writes: 

> On Mon, 17 Jun 2002, Pierangelo Masarati wrote: 
>> > OpenLDAP 2.1.2 seems to currupt non-ASCII UTF-8 encoded characters.
>> > It actually turns unprintable chars (in the ASCII sense) into \<hexcode>. 
>> I think this is a leftover of when we decided to use UTF8 instead
>> of the '\' + HEXPAIR representation of non-ascii chars, and initially
>> it was intended; of course, when parsing a DN, one wants the correct
>> UTF8 encoding.
> Note that the problem does not exist in 2.0.23...

DN parsing/handling has been completely rewritten 

> To further elaborate the problem: before passing the DN to the
> ldap_explode_dn function it is properly (UTF-8) encoded. Afterwards the DN
> parts aren't...	

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
that DN parsing is delicate when UTF-8 is involved.  The point is
that ldap_explode_dn API is broken, because t doesn't let you choose
how to expand a DN (how to represent it in string form). 

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 ],

see ldap_explode_dn code in libraries/libldap/getdn.c;
the flag LDAP_DN_PRETTY causes UTF-8 to be represented. 

> Is exploding a dn a conversion wrt to codesets? (I would not think it is)
> Where would one need to specify extra flags? Or is this a purely internal
> matter?

No internal matter, only a matter of deciding, among allowed
choiches what's the most general.  Initially I considered
'\' + HEXPAIR the most general. 

Debate is open. 


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