Skip to content

Commit 41bee0a

Browse files
committed
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.
1 parent 41b230d commit 41bee0a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/net/ldap/dataset.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def read_ldif(io)
117117
while line
118118
new_line = io.gets
119119

120-
if new_line =~ /^[\s]+/
121-
line << " " << $'
120+
if new_line =~ /^ /
121+
line << $'
122122
else
123123
nextline = new_line
124124

test/test_ldif.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@ def test_ldif_with_password
3131
end
3232

3333
def test_ldif_with_continuation_lines
34-
ds = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
35-
assert_equal(true, ds.has_key?("abcdefg hijklmn"))
34+
ds = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
35+
assert_equal(true, ds.has_key?("abcdefghijklmn"))
36+
end
37+
38+
def test_ldif_with_continuation_lines_and_extra_whitespace
39+
ds1 = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n"))
40+
assert_equal(true, ds1.has_key?("abcdefg hijklmn"))
41+
ds2 = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hij klmn\r\n\r\n"))
42+
assert_equal(true, ds2.has_key?("abcdefghij klmn"))
3643
end
3744

3845
# TODO, INADEQUATE. We need some more tests

0 commit comments

Comments
 (0)