diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-07-07 03:07:42 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-07-07 03:07:42 +0000 |
commit | 9f3a1d7507eb082d3b7c0c42ae70d753dec82c50 (patch) | |
tree | f373ad53ed7778f24bf3e89cf2711dc0d1504ac2 /lib | |
parent | c8c913c61538f9348cb35a91a10a5155d3a04edd (diff) |
merge revision(s) 40372: [Backport #8167]
* lib/net/imap.rb (body_type_msg): should accept
message/delivery-status with extra data.
[ruby-core:53741] [Bug #8167]
* test/net/imap/test_imap_response_parser.rb: related test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net/imap.rb | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 0ae47c5316..1bb0b81eec 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -2372,6 +2372,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 @@ -2411,27 +2413,26 @@ module Net match(T_SPACE) param, content_id, desc, enc, size = body_fields - # If this is not message/rfc822, we shouldn't apply the RFC822 spec - # to it. - # We should handle anything other than message/rfc822 using - # multipart extension data [rfc3501] (i.e. the data itself won't be - # returned, we would have to retrieve it with BODYSTRUCTURE instead - # of with BODY - if "#{mtype}/#{msubtype}" != 'MESSAGE/RFC822' then - return BodyTypeExtension.new(mtype, msubtype, - param, content_id, - desc, enc, size) - end - - # Also, sometimes a message/rfc822 is included as a large - # attachment instead of having all of the other details - # (e.g. attaching a .eml file to an email) - token = lookahead - if token.symbol == T_RPAR then - return BodyTypeMessage.new(mtype, msubtype, param, content_id, - desc, enc, size, nil, nil, nil, nil, - nil, nil, nil) + if token.symbol == T_RPAR + # If this is not message/rfc822, we shouldn't apply the RFC822 + # spec to it. We should handle anything other than + # message/rfc822 using multipart extension data [rfc3501] (i.e. + # the data itself won't be returned, we would have to retrieve it + # with BODYSTRUCTURE instead of with BODY + + # Also, sometimes a message/rfc822 is included as a large + # attachment instead of having all of the other details + # (e.g. attaching a .eml file to an email) + if msubtype == "RFC822" + return BodyTypeMessage.new(mtype, msubtype, param, content_id, + desc, enc, size, nil, nil, nil, nil, + nil, nil, nil) + else + return BodyTypeExtension.new(mtype, msubtype, + param, content_id, + desc, enc, size) + end end match(T_SPACE) @@ -2455,6 +2456,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 |