Skip to content

Rebase #168: Connection#unescape handles numerics, #search guards against nil queued_reads #184

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

Merged
merged 5 commits into from
Jan 8, 2015
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Contributors.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ Contributions since:
* nowhereman
* David J. Lee (DavidJLee)
* Cody Cutrer (ccutrer)
* WoodsBagotAndreMarquesLee
3 changes: 2 additions & 1 deletion lib/net/ldap/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,13 @@ def search(args = nil)
result_pdu || OpenStruct.new(:status => :failure, :result_code => Net::LDAP::ResultCodeOperationsError, :message => "Invalid search")
end # instrument
ensure

# clean up message queue for this search
messages = message_queue.delete(message_id)

# in the exceptional case some messages were *not* consumed from the queue,
# instrument the event but do not fail.
unless messages.empty?
if !messages.nil? && !messages.empty?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

instrument "search_messages_unread.net_ldap_connection",
message_id: message_id, messages: messages
end
Expand Down
3 changes: 1 addition & 2 deletions lib/net/ldap/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,8 @@ def match(entry)

##
# Converts escaped characters (e.g., "\\28") to unescaped characters
# ("(").
def unescape(right)
right.gsub(/\\([a-fA-F\d]{2})/) { [$1.hex].pack("U") }
right.to_s.gsub(/\\([a-fA-F\d]{2})/) { [$1.hex].pack("U") }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

end
private :unescape

Expand Down
5 changes: 5 additions & 0 deletions test/test_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,9 @@ def test_parse_ber_escapes_characters
filter = Net::LDAP::Filter.parse_ber(ber.read_ber(Net::LDAP::AsnSyntax))
assert_equal "(objectclass=#{escaped}*#{escaped}*#{escaped})", filter.to_s
end

def test_unescape_fixnums
filter = Net::LDAP::Filter.eq("objectclass", 3)
assert_equal "\xA3\x10\x04\vobjectclass\x04\x013".b, filter.to_ber
end
end