From f2d761794fa259f0315406c794a46a38f0caa95f Mon Sep 17 00:00:00 2001 From: blackhedd Date: Thu, 31 Aug 2006 01:48:33 +0000 Subject: [PATCH] tweaked the binary-attribute check. Now we look at the whole string instead of just the ends as ldapsearch does. --- lib/net/ldap/entry.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/net/ldap/entry.rb b/lib/net/ldap/entry.rb index 6bb810e..ce19cdd 100644 --- a/lib/net/ldap/entry.rb +++ b/lib/net/ldap/entry.rb @@ -236,13 +236,13 @@ class LDAP # Internal convenience method. It seems like the standard # approach in most LDAP tools to base64 encode an attribute # value if its first or last byte is nonprintable, or if - # it's a password. + # it's a password. But that turns out to be not nearly good + # enough. There are plenty of A/D attributes that are binary + # in the middle. This is probably a nasty performance killer. def is_attribute_value_binary? value v = value.to_s - [v[0],v[-1]].each {|byt| - if byt.is_a?(Fixnum) and (byt < 33 or byt > 126) - return true - end + v.each_byte {|byt| + return true if (byt < 33) || (byt > 126) } if v[0..0] == ':' or v[0..0] == '<' return true