diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-08 06:46:18 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-08 06:46:18 +0000 |
commit | f954f0d8404059b2be73d382e3166ecc1076a3c0 (patch) | |
tree | 9aedbec83897dcc7a6bddd40cde281b816a63be0 | |
parent | a64ec79c8e8061311a2dcd0c179e2f115b9c7004 (diff) | |
download | ruby-f954f0d8404059b2be73d382e3166ecc1076a3c0.tar.gz |
* lib/net/imap.rb (body_ext_mpart): should work even if body-fld-dsp
is omitted. [ruby-core:69093] [Bug #11128]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/net/imap.rb | 8 | ||||
-rw-r--r-- | test/net/imap/test_imap_response_parser.rb | 13 |
3 files changed, 25 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Fri May 8 15:43:11 2015 Shugo Maeda <shugo@ruby-lang.org> + + * lib/net/imap.rb (body_ext_mpart): should work even if body-fld-dsp + is omitted. [ruby-core:69093] [Bug #11128] + Fri May 8 15:05:57 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org> * doc/syntax/control_expressions.rdoc: fix a missing "a" diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 95e68ae9c1..1cf7aa4ee2 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -2639,7 +2639,13 @@ module Net return param end disposition = body_fld_dsp - match(T_SPACE) + + token = lookahead + if token.symbol == T_SPACE + shift_token + else + return param, disposition + end language = body_fld_lang token = lookahead diff --git a/test/net/imap/test_imap_response_parser.rb b/test/net/imap/test_imap_response_parser.rb index ded7dd1eff..1612d78e87 100644 --- a/test/net/imap/test_imap_response_parser.rb +++ b/test/net/imap/test_imap_response_parser.rb @@ -276,4 +276,17 @@ EOF assert_equal("SEARCH", response.name) assert_equal([87216, 87221], response.data) end + + # [Bug #11128] + def test_body_ext_mpart_without_lang + parser = Net::IMAP::ResponseParser.new + response = parser.parse("* 4 FETCH (BODY (((\"text\" \"plain\" (\"charset\" \"utf-8\") NIL NIL \"7bit\" 257 9 NIL NIL NIL NIL)(\"text\" \"html\" (\"charset\" \"utf-8\") NIL NIL \"quoted-printable\" 655 9 NIL NIL NIL NIL) \"alternative\" (\"boundary\" \"001a1137a5047848dd05157ddaa1\") NIL)(\"application\" \"pdf\" (\"name\" \"test.xml\" \"x-apple-part-url\" \"9D00D9A2-98AB-4EFB-85BA-FB255F8BF3D7\") NIL NIL \"base64\" 4383638 NIL (\"attachment\" (\"filename\" \"test.xml\")) NIL NIL) \"mixed\" (\"boundary\" \"001a1137a5047848e405157ddaa3\") NIL))\r\n") + assert_equal("FETCH", response.name) + body = response.data.attr["BODY"] + assert_equal(nil, body.parts[0].disposition) + assert_equal(nil, body.parts[0].language) + assert_equal("ATTACHMENT", body.parts[1].disposition.dsp_type) + assert_equal("test.xml", body.parts[1].disposition.param["FILENAME"]) + assert_equal(nil, body.parts[1].language) + end end |