From 878ea0639f13fe89e2644e517e0771a449102033 Mon Sep 17 00:00:00 2001 From: David Albert Date: Fri, 12 Jul 2013 02:18:59 -0400 Subject: [PATCH] Fix response parsing bug in Ruby 2.0 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. --- lib/net/imap/response_parser/gmail.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/net/imap/response_parser/gmail.rb b/lib/net/imap/response_parser/gmail.rb index 676512f..142701d 100644 --- a/lib/net/imap/response_parser/gmail.rb +++ b/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 @@ -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