ruby-changes:34650
From: usa <ko1@a...>
Date: Mon, 7 Jul 2014 12:07:48 +0900 (JST)
Subject: [ruby-changes:34650] usa:r46733 (ruby_2_0_0): merge revision(s) 40372: [Backport #8167]
usa 2014-07-07 12:07:42 +0900 (Mon, 07 Jul 2014) New Revision: 46733 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46733 Log: 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. Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/lib/net/imap.rb branches/ruby_2_0_0/test/net/imap/test_imap_response_parser.rb branches/ruby_2_0_0/version.h Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 46732) +++ ruby_2_0_0/ChangeLog (revision 46733) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Mon Jul 7 12:05:28 2014 Shugo Maeda <shugo@r...> + + * 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. + Mon Jul 7 11:47:51 2014 Nobuyoshi Nakada <nobu@r...> * parse.y (local_tbl_gen): remove local variables duplicated with Index: ruby_2_0_0/lib/net/imap.rb =================================================================== --- ruby_2_0_0/lib/net/imap.rb (revision 46732) +++ ruby_2_0_0/lib/net/imap.rb (revision 46733) @@ -2372,6 +2372,8 @@ module Net https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/net/imap.rb#L2372 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 https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/net/imap.rb#L2413 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 https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/net/imap.rb#L2456 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 Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 46732) +++ ruby_2_0_0/version.h (revision 46733) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2014-07-07" -#define RUBY_PATCHLEVEL 517 +#define RUBY_PATCHLEVEL 518 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 7 Index: ruby_2_0_0/test/net/imap/test_imap_response_parser.rb =================================================================== --- ruby_2_0_0/test/net/imap/test_imap_response_parser.rb (revision 46732) +++ ruby_2_0_0/test/net/imap/test_imap_response_parser.rb (revision 46733) @@ -205,4 +205,47 @@ EOF https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/net/imap/test_imap_response_parser.rb#L205 assert_equal("CAPABILITY", response.name) assert_equal("AUTH=PLAIN", response.data.last) end + + # [Bug #8167] + def test_msg_delivery_status_with_extra_data + parser = Net::IMAP::ResponseParser.new + response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint) +* 29021 FETCH (RFC822.SIZE 3162 UID 113622 RFC822.HEADER {1155} +Return-path: <> +Envelope-to: info@x... +Delivery-date: Tue, 26 Mar 2013 12:42:58 +0100 +Received: from mail by xxxx.xxxxxxxxxxx.net with spam-scanned (Exim 4.76) + id 1UKSHI-000Cwl-AR + for info@x...; Tue, 26 Mar 2013 12:42:58 +0100 +X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on xxxx.xxxxxxxxxxx.net +X-Spam-Level: ** +X-Spam-Status: No, score=2.1 required=7.0 tests=DKIM_ADSP_NXDOMAIN,RDNS_NONE + autolearn=no version=3.3.1 +Received: from [xx.xxx.xxx.xx] (port=56890 helo=xxxxxx.localdomain) + by xxxx.xxxxxxxxxxx.net with esmtp (Exim 4.76) + id 1UKSHI-000Cwi-9j + for info@x...; Tue, 26 Mar 2013 12:42:56 +0100 +Received: by xxxxxx.localdomain (Postfix) + id 72725BEA64A; Tue, 26 Mar 2013 12:42:55 +0100 (CET) +Date: Tue, 26 Mar 2013 12:42:55 +0100 (CET) +From: MAILER-DAEMON@x... (Mail Delivery System) +Subject: Undelivered Mail Returned to Sender +To: info@x... +Auto-Submitted: auto-replied +MIME-Version: 1.0 +Content-Type: multipart/report; report-type=delivery-status; + boundary="27797BEA649.1364298175/xxxxxx.localdomain" +Message-Id: <20130326114255.72725BEA64A@x...> + + BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL "Notification" "7bit" 510 14 NIL NIL NIL NIL)("message" "delivery-status" NIL NIL "Delivery report" "7bit" 410 NIL NIL NIL NIL)("text" "rfc822-headers" ("charset" "us-ascii") NIL "Undelivered Message Headers" "7bit" 612 15 NIL NIL NIL NIL) "report" ("report-type" "delivery-status" "boundary" "27797BEA649.1364298175/xxxxxx.localdomain") NIL NIL NIL)) +EOF + delivery_status = response.data.attr["BODYSTRUCTURE"].parts[1] + assert_equal("MESSAGE", delivery_status.media_type) + assert_equal("DELIVERY-STATUS", delivery_status.subtype) + assert_equal(nil, delivery_status.param) + assert_equal(nil, delivery_status.content_id) + assert_equal("Delivery report", delivery_status.description) + assert_equal("7BIT", delivery_status.encoding) + assert_equal(410, delivery_status.size) + end end Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r40372,46331 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/