Skip to content

Commit

Permalink
Fix response parsing bug in Ruby 2.0
Browse files Browse the repository at this point in the history
The signature of Net::IMAP::ResponseParser#msg_att has changed in ruby
2.0.0. You can see the relevant issue here:
http://bugs.ruby-lang.org/issues/5692

and the diff here:
http://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/34010

This change caused some tests to fail when using gmail-imap 1.0.1 with
Ruby 2.0. This patch adjusts to the new function signature while still
allowing the library to work in versions of ruby older than 2.0. I've
run the test suite on 1.9.3-p448 and 2.0.0-p247 and verified that
everything works. The fix is pretty gross, but I didn't see a better way
to do it.
  • Loading branch information
davidbalbert committed Jul 12, 2013
1 parent edddae2 commit 878ea06
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/net/imap/response_parser/gmail.rb
@@ -1,5 +1,5 @@
class Net::IMAP::ResponseParser::Gmail < Net::IMAP::ResponseParser
def msg_att
def msg_att(n = nil)
match(T_LPAR)
attr = {}
while true
Expand Down Expand Up @@ -34,7 +34,11 @@ def msg_att
when /\A(?:X-GM-THRID)\z/ni
name, val = uid_data
else
parse_error("unknown attribute `%s'", token.value)
if n # Ruby >= 2.0.0
parse_error("unknown attribute `%s' for {%d}", token.value, n)
else # Ruby <= 1.9.3
parse_error("unknown attribute `%s'", token.value)
end
end
attr[name] = val
end
Expand Down

0 comments on commit 878ea06

Please sign in to comment.