Skip to content

Commit 089abcc

Browse files
author
blackhedd
committed
Applied patch from Kouhei Sutou
1 parent e429d70 commit 089abcc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/net/ldap/filter.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ def to_ber
208208
end
209209
[@left.to_s.to_ber, seq.to_ber].to_ber_contextspecific 4
210210
else #equality
211-
[@left.to_s.to_ber, @right.to_ber].to_ber_contextspecific 3
211+
[@left.to_s.to_ber, unescape(@right).to_ber].to_ber_contextspecific 3
212212
end
213213
when :ge
214-
[@left.to_s.to_ber, @right.to_ber].to_ber_contextspecific 5
214+
[@left.to_s.to_ber, unescape(@right).to_ber].to_ber_contextspecific 5
215215
when :le
216-
[@left.to_s.to_ber, @right.to_ber].to_ber_contextspecific 6
216+
[@left.to_s.to_ber, unescape(@right).to_ber].to_ber_contextspecific 6
217217
when :and
218218
ary = [@left.coalesce(:and), @right.coalesce(:and)].flatten
219219
ary.map {|a| a.to_ber}.to_ber_contextspecific( 0 )
@@ -229,6 +229,12 @@ def to_ber
229229
end
230230
end
231231

232+
def unescape(right)
233+
right.gsub(/\\([a-fA-F\d]{2,2})/) do
234+
[$1.hex].pack("U")
235+
end
236+
end
237+
232238

233239
# Converts an LDAP search filter in BER format to an Net::LDAP::Filter
234240
# object. The incoming BER object most likely came to us by parsing an

0 commit comments

Comments
 (0)