diff --git a/lib/net/ldap/dataset.rb b/lib/net/ldap/dataset.rb index 363d259..ffdee11 100644 --- a/lib/net/ldap/dataset.rb +++ b/lib/net/ldap/dataset.rb @@ -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 diff --git a/test/test_ldif.rb b/test/test_ldif.rb index 77f8b86..275456a 100644 --- a/test/test_ldif.rb +++ b/test/test_ldif.rb @@ -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