File tree Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -644,18 +644,9 @@ def match(entry)
644644 end
645645
646646 ##
647- # If the argument is a string, converts escaped characters (e.g., "\\28") to unescaped characters.
648- # If the argument is a number, just return as-is.
649- # Otherwise, an exception is thrown and the rhs argument is rejected.
650- # ("(").
647+ # Converts escaped characters (e.g., "\\28") to unescaped characters
651648 def unescape ( right )
652- if defined? right . gsub
653- right . gsub ( /\\ ([a-fA-F\d ]{2})/ ) { [ $1. hex ] . pack ( "U" ) }
654- elsif right . is_a? Fixnum
655- right . to_s
656- else
657- raise ArgumentError , "Did not know how to convert argument \" #{ right } \" into the rhs of an LDAP filter"
658- end
649+ right . to_s . gsub ( /\\ ([a-fA-F\d ]{2})/ ) { [ $1. hex ] . pack ( "U" ) }
659650 end
660651 private :unescape
661652
Original file line number Diff line number Diff line change @@ -215,4 +215,9 @@ def test_parse_ber_escapes_characters
215215 filter = Net ::LDAP ::Filter . parse_ber ( ber . read_ber ( Net ::LDAP ::AsnSyntax ) )
216216 assert_equal "(objectclass=#{ escaped } *#{ escaped } *#{ escaped } )" , filter . to_s
217217 end
218+
219+ def test_unescape_fixnums
220+ filter = Net ::LDAP ::Filter . eq ( "objectclass" , 3 )
221+ assert_equal "\xA3 \x10 \x04 \v objectclass\x04 \x01 3" . b , filter . to_ber
222+ end
218223end
You can’t perform that action at this time.
0 commit comments