Skip to content

Commit f2d7617

Browse files
author
blackhedd
committed
tweaked the binary-attribute check. Now we look at the
whole string instead of just the ends as ldapsearch does.
1 parent 1deab24 commit f2d7617

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/net/ldap/entry.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ def write
236236
# Internal convenience method. It seems like the standard
237237
# approach in most LDAP tools to base64 encode an attribute
238238
# value if its first or last byte is nonprintable, or if
239-
# it's a password.
239+
# it's a password. But that turns out to be not nearly good
240+
# enough. There are plenty of A/D attributes that are binary
241+
# in the middle. This is probably a nasty performance killer.
240242
def is_attribute_value_binary? value
241243
v = value.to_s
242-
[v[0],v[-1]].each {|byt|
243-
if byt.is_a?(Fixnum) and (byt < 33 or byt > 126)
244-
return true
245-
end
244+
v.each_byte {|byt|
245+
return true if (byt < 33) || (byt > 126)
246246
}
247247
if v[0..0] == ':' or v[0..0] == '<'
248248
return true

0 commit comments

Comments
 (0)