empty attribute values are being treated falsely as parsing error
nikkicoon opened this issue · comments
Is a linebreak considered an empty value?
b, err := os.ReadFile(*f)
if err != nil {
fmt.Println(err)
}
res, err = pkg.ParseUsers(string(b))
where ParseUsers(b) is a function which utilizes ldif.Parse, for an ldif file with several entries I get "Error in line 29: empty value" even when I cut it down to the first two chunks of entries and the file has no line 29 (sorry for the words used, I merely write code which deals with data I get handed and don't have much experience with ldap).
My assumption from the ldif dump I got, and the tests I've seen in your code, is that ldif entries are separated by linebreaks. Why does this happen?
it is possible that the file I was given as an example was mangled
5) When a zero-length attribute value is to be included directly
in an LDIF file, it MUST be represented as
AttributeDescription ":" FILL SEP. For example, "seeAlso:"
followed by a newline represents a zero-length "seeAlso"
attribute value. It is also permissible for the value
referred to by a URL to be of zero length.
quote from https://datatracker.ietf.org/doc/html/rfc2849
yet you seem to handle empty attribute values as errors.
rough solution: https://github.com/nikkicoon/ldif/commits/master/?since=2024-06-17&until=2024-06-17
If you give me feedback, I can polish this up and send in a proper PR. I'm not that interested in maintaining a solution for my company only if it can be avoided.
This does treat no empty attribute value as error, which - in my understanding of the specs - should be spec conform.