[python-ldap] Inconsistent capitalization breaks schema parsing

Petr Viktorin pviktori at redhat.com
Wed Sep 18 13:46:38 CEST 2013


On 09/13/2013 08:04 PM, Michael Ströder wrote:
> Petr Viktorin wrote:
>> Is this the proper place to bring bugs to the attention of python-ldap
>> developers?
>
> Yes.
>
> Thanks for reporting issues here.
>
>> I've noticed that inconsistent capitalization of attributes in a schema LDIF
>> file can result in a SubSchema with some entries missing.
>> Use the attached files to reproduce the issue.
>>
>> The problem is that the LDIF parsing yields to something like
>> `{'attributeTypes': [...], 'attributetypes': [...]}`, but when that is
>> converted to a case-insensitive dict, one of the keys overwrites the other.
>>
>> I'm not sure where to do a proper fix. Clean up the dictionary before
>> converting? Modify the LDIF parser to normalize attribute names to the first
>> value seen? Modify cidict to optionally handle conflicts like these?
>
> For now I've added a work-around in function ldap.schema.subentry.urlfetch():
>
> http://python-ldap.cvs.sourceforge.net/viewvc/python-ldap/python-ldap/Lib/ldap/schema/subentry.py?r1=1.33&r2=1.34
>
> The down-side is that it might not perform very well since list.extend() is
> used and usually lots of attribute values are in the schema per multi-valued
> attribute.
>
> Please test and provide feedback.
>
> Ciao, Michael.

It works well in my testing so far, thank you!
I don't think performance is too bad, either -- list.extend() isn't 
called too many times.

-- 
Petr³



More information about the python-ldap mailing list