Skip to content

Commit 82e2cc3

Browse files
author
blackhedd
committed
Fixed bug noticed by Matthias Tarasiewicz: from_single_ldif_string
was returning DN attributes with a prepended nil element.
1 parent 14c3db9 commit 82e2cc3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/net/ldap/entry.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,20 @@ def to_ldif
184184
# Eventually, we should have a class method that parses large LDIF
185185
# streams into individual LDIF blocks (delimited by blank lines)
186186
# and passes them here.
187+
#
188+
# There is one oddity, noticed by Matthias Tarasiewicz: as originally
189+
# written, this code would return an Entry object in which the DN
190+
# attribute consisted of a two-element array, and the first element was
191+
# nil. That's because Entry#initialize doesn't like to create an object
192+
# without a DN attribute so it adds one: nil. The workaround here is
193+
# to wipe out the nil DN after creating the Entry object, and trust the
194+
# LDIF string to fill it in. If it doesn't we return a nil at the end.
195+
# (30Sep06, FCianfrocca)
196+
#
187197
class << self
188198
def from_single_ldif_string ldif
189199
entry = Entry.new
200+
entry[:dn] = []
190201
ldif.split(/\r?\n/m).each {|line|
191202
break if line.length == 0
192203
if line =~ /\A([\w]+):(:?)[\s]*/

0 commit comments

Comments
 (0)