summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-16 04:56:18 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-16 04:56:18 +0000
commited07df5ab5e183aed62cbe33f50a57640617d7a4 (patch)
tree480a7ea5ab934a9cd7876cb372f51c6b71a11e96
parent5308538befe847d3b9774257a54d9c4d5b47bd94 (diff)
* lib/net/imap.rb (rfc822_text): ignore [] after RFC822.
[ruby-core:40945] [Bug #5620] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/net/imap.rb5
-rw-r--r--test/net/imap/test_imap_response_parser.rb16
3 files changed, 26 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c1af24483a..49c606b244 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Mar 16 13:50:12 2012 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb (rfc822_text): ignore [] after RFC822.
+ [ruby-core:40945] [Bug #5620]
+
Fri Mar 16 12:00:42 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (argument_error): use line number at the beginning
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index c8faf97c11..b2193dbf93 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -2281,6 +2281,11 @@ module Net
def rfc822_text
token = match(T_ATOM)
name = token.value.upcase
+ token = lookahead
+ if token.symbol == T_LBRA
+ shift_token
+ match(T_RBRA)
+ end
match(T_SPACE)
return name, nstring
end
diff --git a/test/net/imap/test_imap_response_parser.rb b/test/net/imap/test_imap_response_parser.rb
index 3f26e0b350..b4d36c9091 100644
--- a/test/net/imap/test_imap_response_parser.rb
+++ b/test/net/imap/test_imap_response_parser.rb
@@ -126,4 +126,20 @@ EOF
}
assert_match(/ for \{123\}/, e.message)
end
+
+ def test_msg_att_rfc822_text
+ parser = Net::IMAP::ResponseParser.new
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+* 123 FETCH (RFC822 {5}
+foo
+)
+EOF
+ assert_equal("foo\r\n", response.data.attr["RFC822"])
+ response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+* 123 FETCH (RFC822[] {5}
+foo
+)
+EOF
+ assert_equal("foo\r\n", response.data.attr["RFC822"])
+ end
end