Closed kpopovic closed 1 year ago
Mentioning this here just to save someone else the research: I had thought that LDIF was invalid and values containing :
had to be base64-encoded, but it looks from RFC 2849 like I'm wrong and colons are allowed in values as long as the colon isn't the first character. I think it's generally recommended to base64-encode such values, but since it can be unambiguously parsed, it's apparently not required.
Hello,
I have adapted my code to work with ldif file I have.
But maybe small recommendation for the future, improvement:
Maybe to improve parsing in case of ": "
elif ": " in attrval:
attr, val = attrval.split(": ", 1) # maxsplit=1, instead of 0
...
except:
raise LDIFError(
f"Invalid attribute value pair: '{attrval}' for entry #{self.__num_of_entries}."
) from None
Or just to improve error description:
except Exception as ex:
raise LDIFError(
f"Invalid attribute value pair: '{attrval}' for entry #{self.__num_of_entries}., {ex}"
) from None # better description why error happend...
Hi, thanks for reporting it. I added both of your recommendations:
maxsplit
for splitting text lines, so colons in values will be accepted, unless it's the first character.ValueError
exceptions will be reraised as part of the exception chains.You can see the changes in the linked commits
The fix has been release in 1.5.1.
Hello,
I have and issue with
LDIFReader
It throws an error in case ofpostaladdress
. As it can be seen it contains colon inP.O.Box:
This causes ldif.py to break in methoddef __next__(self) -> LDAPEntry:
This will return error ValueError: too many values to unpack (expected 2)
I use bonsai==1.5.0.