-
Notifications
You must be signed in to change notification settings - Fork 252
Bug fixes to 0.9.0 #168
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
Bug fixes to 0.9.0 #168
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -644,10 +644,18 @@ def match(entry) | |
end | ||
|
||
## | ||
# Converts escaped characters (e.g., "\\28") to unescaped characters | ||
# If the argument is a string, converts escaped characters (e.g., "\\28") to unescaped characters. | ||
# If the argument is a number, just return as-is. | ||
# Otherwise, an exception is thrown and the rhs argument is rejected. | ||
# ("("). | ||
def unescape(right) | ||
right.gsub(/\\([a-fA-F\d]{2})/) { [$1.hex].pack("U") } | ||
if defined? right.gsub | ||
right.gsub(/\\([a-fA-F\d]{2})/) { [$1.hex].pack("U") } | ||
elsif right.is_a? Fixnum | ||
right.to_s | ||
else | ||
raise ArgumentError, "Did not know how to convert argument \"#{right}\" into the rhs of an LDAP filter" | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be comfortable with always calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, add a simple test to make sure this works! :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in b133b31 |
||
end | ||
private :unescape | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were you able to reproduce this problem reliably? Would love to add a test case for this scenario.
Use
||
instead ofor
here.I tend to only use
unless
in cases with single conditions and switch to the more explicitly but easier to reason aboutif
conditions otherwise. This would be:This is probably fine, though, since it's still a very simple case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This scenario is possible, but it's really hard to test.
message_queue
will always return a hash, but thedelete
can returnnil
ifmessage_id
isn't in that hash. I tried testing this with stubs, butqueued_read
will loop forever trying to read additional pdf's, so this code is never reached. In real life, the socket would terminate at some point, and thisensure
block would run, but I don't know how to simulate that in a test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed style in f046564