Skip to content

Commit 605945f

Browse files
author
Timur Alperovich
committed
Ignore invalid characters in strings.
Multiple ADs return invalid characters and we should ignore them. This is the same as the pull request 44 on the original project.
1 parent f7b796c commit 605945f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/net/ber/core_ext/string.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def raw_utf8_encoded
2929
# Strings should be UTF-8 encoded according to LDAP.
3030
# However, the BER code is not necessarily valid UTF-8
3131
begin
32-
self.encode('UTF-8').force_encoding('ASCII-8BIT')
32+
self.encode('UTF-8', :invalid => :replace, :undef => :replace,
33+
:replace => '').force_encoding('ASCII-8BIT')
3334
rescue Encoding::UndefinedConversionError
3435
self
3536
end

0 commit comments

Comments
 (0)