Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Exception: incompatible character encodings: ASCII-8BIT and UTF-8 in filter.rb #285

Merged
merged 1 commit into from
Nov 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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