summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-03 04:19:57 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-03 04:19:57 +0000
commit87505dd7714b6311c58589752f1f5331ac1d9b1a (patch)
tree4355feb8f8708bfa2cf3298cfe5fd0e4edcbb030
parente7d8c473c17540dbc0b360efd689fbd2def69967 (diff)
* lib/net/imap.rb (body_type_1part): Gmail IMAP reports a body
type as "MIXED" followed immediately by params [ruby-core:62864] [Bug #9885] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--lib/net/imap.rb9
-rw-r--r--test/net/imap/test_imap_response_parser.rb10
3 files changed, 27 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 52035b900f7..d9a5666e185 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Jun 3 13:14:04 2014 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb (body_type_1part): Gmail IMAP reports a body
+ type as "MIXED" followed immediately by params
+ [ruby-core:62864] [Bug #9885]
+ Patch by @rayners (David Raynes). [Fixes GH-622]
+ https://github.com/ruby/ruby/pull/622
+
Tue Jun 3 13:18:24 2014 Koichi Sasada <ko1@atdot.net>
* gc.c (objspace_live_slot): live slot count should not include final
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 2e0f5580548..9f8ad7b2738 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -2374,6 +2374,8 @@ module Net
return body_type_msg
when /\A(?:ATTACHMENT)\z/ni
return body_type_attachment
+ when /\A(?:MIXED)\z/ni
+ return body_type_mixed
else
return body_type_basic
end
@@ -2456,6 +2458,13 @@ module Net
return BodyTypeAttachment.new(mtype, nil, param)
end
+ def body_type_mixed
+ mtype = "MULTIPART"
+ msubtype = case_insensitive_string
+ param, disposition, language, extension = body_ext_mpart
+ return BodyTypeBasic.new(mtype, msubtype, param, nil, nil, nil, nil, nil, disposition, language, extension)
+ end
+
def body_type_mpart
parts = []
while true
diff --git a/test/net/imap/test_imap_response_parser.rb b/test/net/imap/test_imap_response_parser.rb
index 3dc9d972db3..497f430ea42 100644
--- a/test/net/imap/test_imap_response_parser.rb
+++ b/test/net/imap/test_imap_response_parser.rb
@@ -248,4 +248,14 @@ EOF
assert_equal("CAPABILITY", response.name)
assert_equal("AUTH=PLAIN", response.data.last)
end
+
+ def test_mixed_boundry
+ parser = Net::IMAP::ResponseParser.new
+ response = parser.parse("* 2688 FETCH (UID 179161 BODYSTRUCTURE ((\"TEXT\" \"PLAIN\" (\"CHARSET\" \"iso-8859-1\") NIL NIL \"QUOTED-PRINTABLE\" 200 4 NIL NIL NIL)(\"MESSAGE\" \"DELIVERY-STATUS\" NIL NIL NIL \"7BIT\" 318 NIL NIL NIL)(\"MESSAGE\" \"RFC822\" NIL NIL NIL \"7BIT\" 2177 (\"Tue, 11 May 2010 18:28:16 -0400\" \"Re: Welcome letter\" ((\"David\" NIL \"info\" \"xxxxxxxx.si\")) ((\"David\" NIL \"info\" \"xxxxxxxx.si\")) ((\"David\" NIL \"info\" \"xxxxxxxx.si\")) ((\"Doretha\" NIL \"doretha.info\" \"xxxxxxxx.si\")) NIL NIL \"<AC1D15E06EA82F47BDE18E851CC32F330717704E@localdomain>\" \"<AANLkTikKMev1I73L2E7XLjRs67IHrEkb23f7ZPmD4S_9@localdomain>\") (\"MIXED\" (\"BOUNDARY\" \"000e0cd29212e3e06a0486590ae2\") NIL NIL) 37 NIL NIL NIL) \"REPORT\" (\"BOUNDARY\" \"16DuG.4XbaNOvCi.9ggvq.8Ipnyp3\" \"REPORT-TYPE\" \"delivery-status\") NIL NIL))\r\n")
+ empty_part = response.data.attr['BODYSTRUCTURE'].parts[2]
+ assert_equal(empty_part.lines, 37)
+ assert_equal(empty_part.body.media_type, 'MULTIPART')
+ assert_equal(empty_part.body.subtype, 'MIXED')
+ assert_equal(empty_part.body.param['BOUNDARY'], '000e0cd29212e3e06a0486590ae2')
+ end
end