[python-ldap] feature request: be more lenient in LDIFParser

Michael Ströder michael at stroeder.com
Wed Mar 23 13:33:31 EDT 2016


Jephte Clain wrote:
> FYI, I made feature request #18 on
> http://sourceforge.net/p/python-ldap/feature-requests/18/ to make
> LDIFParser more lenient

I saw your feature request and patch.

> from the "be lenient with what you parse, be strict in what you write"
> departement, I attach a patch which support ldif input with several
> blank and/or comment lines between objects
> I don't know if this behavior is correct wrt the LDIF standard, but it
> is useful for me, because I have LDIF files with comments written by
> humans, e.g:

Even line-folded comments are parsed correctly (I've added a test-case to
Tests/t_ldif.py).

> # silly example
> dn: uid=one,dc=tld
> uid: one
> 
> # another silly example
> dn: uid=two,dc=tld
> uid: two
>
> with the current parser, uid=two is not read because there are two
> "blanks" lines before

The example above parses correctly.
You probably meant:

------------------------ snip ------------------------
# silly example
dn: uid=one,dc=tld
uid: one


# another silly example
dn: uid=two,dc=tld
uid: two

------------------------ snip ------------------------

Anyway, please test CVS HEAD.

Ciao, Michael.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4245 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20160323/973734d2/attachment.bin>


More information about the python-ldap mailing list