Fix LDIF contination to single elided space
RFC 2849 http://tools.ietf.org/html/rfc2849: SPACE = %x20 ; ASCII SP, space ... 2) Any non-empty line, including comment lines, in an LDIF file MAY be folded by inserting a line separator (SEP) and a SPACE. Folding MUST NOT occur before the first character of the line. In other words, folding a line into two lines, the first of which is empty, is not permitted. Any line that begins with a single space MUST be treated as a continuation of the previous (non-empty) line. When joining folded lines, exactly one space character at the beginning of each continued line must be discarded. Implementations SHOULD NOT fold lines in the middle of a multi-byte UTF-8 character.
This commit is contained in:
parent
41b230d9bc
commit
41bee0a690
2 changed files with 11 additions and 4 deletions
|
@ -117,8 +117,8 @@ class Net::LDAP::Dataset < Hash
|
|||
while line
|
||||
new_line = io.gets
|
||||
|
||||
if new_line =~ /^[\s]+/
|
||||
line << " " << $'
|
||||
if new_line =~ /^ /
|
||||
line << $'
|
||||
else
|
||||
nextline = new_line
|
||||
|
||||
|
|
|
@ -31,8 +31,15 @@ class TestLdif < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_ldif_with_continuation_lines
|
||||
ds = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
|
||||
assert_equal(true, ds.has_key?("abcdefg hijklmn"))
|
||||
ds = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
|
||||
assert_equal(true, ds.has_key?("abcdefghijklmn"))
|
||||
end
|
||||
|
||||
def test_ldif_with_continuation_lines_and_extra_whitespace
|
||||
ds1 = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
|
||||
assert_equal(true, ds1.has_key?("abcdefg hijklmn"))
|
||||
ds2 = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hij klmn\r\n\r\n"))
|
||||
assert_equal(true, ds2.has_key?("abcdefghij klmn"))
|
||||
end
|
||||
|
||||
# TODO, INADEQUATE. We need some more tests
|
||||
|
|
Loading…
Reference in a new issue