Open twiz718 opened 11 years ago
The problem is that ruby-ldap was not written to work with UTF-8, and method unsafe_char?
fails when parsing a file
# return *true* if +str+ contains a character with an ASCII value > 127 or
# a NUL, LF or CR. Otherwise, *false* is returned.
#
def LDIF.unsafe_char?( str )
# This could be written as a single regex, but this is faster.
str =~ /^[ :]/ || str =~ /[\x00-\x1f\x7f-\xff]/
end
Wikipedia:
ASCII was incorporated into the Unicode character set as the first 128 symbols, so the ASCII characters have the same numeric codes in both sets. This allows UTF-8 to be backward compatible with ASCII, a significant advantage.
so, sequence \x00-\x1f
is correct and pass, but \x7f-\xff
is invalid in UTF-8 and should be replaced to another one or even few sequences, but I do not know on which exactly
Patches are welcome.
This file:///var/tmp/ldapsearch-thumbnailPhoto-S8oDGY exists and is readable (contains JPEG data).
If you try to run a
LDAP::LDIF.parse_file()
on this ldif you get the following error:When I run "file" on that thumbnailPhoto I get the following:
ldapsearch-thumbnailPhoto-S8oDGY: JPEG image data, JFIF standard 1.01
Now if I remove the last line in the ldif (with the thumbnail ":<" reference), it parses just fine.