Skip to content

Commit f0d74c4

Browse files
author
Jerry Cheung
committed
Merge remote-tracking branch 'WoodsBagotAndreMarquesLee/release-0.9.0' into rebase-168-nil-guard-numeric-unescape
2 parents a89d094 + d286220 commit f0d74c4

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/net/ldap/connection.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,13 @@ def search(args = nil)
571571
result_pdu || OpenStruct.new(:status => :failure, :result_code => Net::LDAP::ResultCodeOperationsError, :message => "Invalid search")
572572
end # instrument
573573
ensure
574+
574575
# clean up message queue for this search
575576
messages = message_queue.delete(message_id)
576577

577578
# in the exceptional case some messages were *not* consumed from the queue,
578579
# instrument the event but do not fail.
579-
unless messages.empty?
580+
unless messages.nil? or messages.empty?
580581
instrument "search_messages_unread.net_ldap_connection",
581582
message_id: message_id, messages: messages
582583
end

lib/net/ldap/filter.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,10 +644,18 @@ def match(entry)
644644
end
645645

646646
##
647-
# Converts escaped characters (e.g., "\\28") to unescaped characters
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.
648650
# ("(").
649651
def unescape(right)
650-
right.gsub(/\\([a-fA-F\d]{2})/) { [$1.hex].pack("U") }
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
651659
end
652660
private :unescape
653661

0 commit comments

Comments
 (0)