Skip to content

Commit

Permalink
Merge pull request #285 from patelanuj28/patch-1
Browse files Browse the repository at this point in the history
Fixed Exception: incompatible character encodings: ASCII-8BIT and UTF-8 in filter.rb
  • Loading branch information
schaary authored Nov 14, 2017
2 parents 258bf07 + 61890b5 commit d78dc1e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/net/ldap/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,15 @@ def match(entry)

##
# Converts escaped characters (e.g., "\\28") to unescaped characters
# @note slawson20170317: Don't attempt to unescape 16 byte binary data which we assume are objectGUIDs
# The binary form of 5936AE79-664F-44EA-BCCB-5C39399514C6 triggers a BINARY -> UTF-8 conversion error
def unescape(right)
right.to_s.gsub(/\\([a-fA-F\d]{2})/) { [$1.hex].pack("U") }
right = right.to_s
if right.length == 16 && right.encoding == Encoding::BINARY
right
else
right.to_s.gsub(/\\([a-fA-F\d]{2})/) { [$1.hex].pack("U") }
end
end
private :unescape

Expand Down

0 comments on commit d78dc1e

Please sign in to comment.