diff options
author | Ricardo Signes <rjbs@cpan.org> | 2013-07-30 09:14:51 -0400 |
---|---|---|
committer | Ricardo Signes <rjbs@cpan.org> | 2013-07-30 09:14:51 -0400 |
commit | 1bed6bef4f8f4ca03e121804b91cd0aa0ebfb2fc (patch) | |
tree | e0a9026dd828176ea31319d1361cb99e6acaad39 /t | |
parent | c899f4a4140a9bca0e5e984b07b290f57deff606 (diff) |
fix behavior of ->body on multipart
Diffstat (limited to 't')
-rw-r--r-- | t/abstractions.t | 36 | ||||
-rw-r--r-- | t/multipart.msg | 94 |
2 files changed, 125 insertions, 5 deletions
diff --git a/t/abstractions.t b/t/abstractions.t index 729e38a..778bbd3 100644 --- a/t/abstractions.t +++ b/t/abstractions.t @@ -1,4 +1,4 @@ -#!perl -T +#!perl use strict; use Test::More; @@ -12,13 +12,13 @@ my @classes plan tests => 2 + (@classes * 2 + 2) * Test::EmailAbstract->tests_per_object + (@classes + 4) * Test::EmailAbstract->tests_per_class - + 2; + + 3; use_ok("Email::Abstract"); -open FILE, '<t/example.msg'; -my $message = do { local $/; <FILE>; }; -close FILE; +open my $fh, '<', 't/example.msg' or die "can't open t/example.msg: $!"; +my $message = do { local $/; <$fh>; }; +close $fh or die "error closing t/example.msg after read: $!"; # Let's be generous and start with real CRLF, no matter what stupid thing the # VCS or archive tools have done to the message. @@ -84,3 +84,29 @@ for my $ref (0..1) { ); } } + +{ + SKIP: { + $tester->load('MIME::Entity'); # cheating!!! -- rjbs, 2013-07-30 + + open my $fh, '<', 't/multipart.msg' or die "can't open t/multipart.msg: $!"; + my $message = do { local $/; <$fh>; }; + close $fh or die "error closing t/multipart.msg after read: $!"; + + # Let's be generous and start with real CRLF, no matter what stupid thing the + # VCS or archive tools have done to the message. + $message =~ s/\x0a\x0d|\x0d\x0a|\x0d|\x0a/\x0d\x0a/g; + + my $parser = MIME::Parser->new; + $parser->output_to_core(1); + my $entity = $parser->parse_data($message); + + my $abstract = Email::Abstract->new($entity); + + like( + $abstract->get_body, + qr/us-ascii/, + "minimal body test on MIME::Entity", + ); + } +} diff --git a/t/multipart.msg b/t/multipart.msg new file mode 100644 index 0000000..fbd9fbc --- /dev/null +++ b/t/multipart.msg @@ -0,0 +1,94 @@ +Return-Path: <SRS0=KeFK=RM=cpan.org=rjbs@bounce2.pobox.com> +X-Original-To: rjbs@[70.87.222.20] +Delivered-To: rjbs@[70.87.222.20] +Received: from gold.pobox.com (gold.pobox.com [208.72.237.26]) by + cancer.codesimply.com (Postfix) with ESMTP id 51C1742273E for + <rjbs@[70.87.222.20]>; Tue, 30 Jul 2013 08:55:58 -0400 (EDT) +Received: from localhost.localdomain (localhost [127.0.0.1]) by + gold.pobox.com (Postfix) with ESMTP id 869DF40B516; Tue, 30 Jul 2013 08:55:56 + -0400 (EDT) +X-Pobox-Filter-Version: 3 +Delivered-To: cpan@rjbs.manxome.org +X-Pobox-Orig-Sender: <rjbs@cpan.org> +X-Pobox-Delivery-ID: + 5ECC6E8A-F917-11E2-BC38-91E4A95B95DF-07314517!gold.pobox.com +x-pobox-client-address: 207.171.7.70 +x-pobox-client-name: x1.develooper.com +Received: from x1.develooper.com (x1.develooper.com [207.171.7.70]) by + gold.pobox.com (Postfix) with SMTP id 900E240A7BB for + <cpan@rjbs.manxome.org>; Tue, 30 Jul 2013 08:55:53 -0400 (EDT) +Received: (qmail 7015 invoked by uid 225); 30 Jul 2013 12:55:52 -0000 +Delivered-To: rjbs@cpan.org +Received: (qmail 7011 invoked by uid 103); 30 Jul 2013 12:55:51 -0000 +Received: from xx1.dev (10.0.100.115) by x1.dev with QMQP; 30 Jul 2013 + 12:55:51 -0000 +Received: from localhost (HELO xx1.develooper.com) (127.0.0.1) by + xx1.develooper.com (qpsmtpd/0.84/v0.84-36-g0b0e4e9) with ESMTP; Tue, 30 Jul + 2013 05:55:51 -0700 +Received: from xx1.develooper.com (xx1.develooper.com [127.0.0.1]) by + localhost (Postfix) with SMTP id B2D9D11FB91 for <rjbs@cpan.org>; Tue, 30 Jul + 2013 05:55:51 -0700 (PDT) +Received: from smtp.pobox.com (b-pb-sasl-quonix.pobox.com [208.72.237.35]) by + xx1.develooper.com (Postfix) with ESMTP id 5248F11FB89 for <rjbs@cpan.org>; + Tue, 30 Jul 2013 05:55:51 -0700 (PDT) +Received: from smtp.pobox.com (unknown [127.0.0.1]) by + b-sasl-quonix.pobox.com (Postfix) with ESMTP id 5656333B7B for + <rjbs@cpan.org>; Tue, 30 Jul 2013 12:55:50 +0000 (UTC) +DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from + :content-type:subject:message-id:date:to:mime-version; s=sasl; + bh=8y5A5fJ5PreQxsLHjgB27fxj+Og=; b=hOKuPVvtMKC87qv6ziDC3DNULjHh + RP0aLBHXUYxJ2YNksTe11d6pJmj/dB1XRR60c/8C48siLnQrBMwX+BjH+aFSi6bE + ZYkZtWxqPZBcSdfVlArkR5UMgh3ERSnlWx/YpeWtMsmqJ3r1rO1hoC44n9rM/VHx + +cW2KqR+tgB3ouk= +Received: from b-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by + b-sasl-quonix.pobox.com (Postfix) with ESMTP id 4B79A33B7A for + <rjbs@cpan.org>; Tue, 30 Jul 2013 12:55:50 +0000 (UTC) +Received: from [172.16.1.202] (unknown [64.121.172.235]) (using TLSv1 with + cipher AES128-SHA (128/128 bits)) (No client certificate requested) by + b-sasl-quonix.pobox.com (Postfix) with ESMTPSA id DABAE33B78 for + <rjbs@cpan.org>; Tue, 30 Jul 2013 12:55:49 +0000 (UTC) +From: Ricardo Signes <rjbs@cpan.org> +Content-Type: multipart/alternative; boundary="Apple-Mail=_FAFF19B4-3BF3-4D29-930E-9D87CEC03F01" +Subject: test of mutipart +Message-Id: <8A1869F4-2A06-4155-8E9C-1B9CEB13D297@cpan.org> +Date: Tue, 30 Jul 2013 08:55:49 -0400 +To: rjbs@cpan.org +Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) +X-Mailer: Apple Mail (2.1508) +X-Pobox-Relay-ID: + 5C183962-F917-11E2-917A-E84251E3A03C-07314517!b-pb-sasl-quonix.pobox.com +X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: + 2013.7.30.124527 +X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' HTML_70_90 0.1, + HTML_NO_HTTP 0.1, FROM_SAME_AS_TO 0.05, MIME_LOWER_CASE 0.05, + BODYTEXTH_SIZE_10000_LESS 0, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1000_LESS + 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_600_699 0, + BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, DKIM_SIGNATURE 0, NO_URI_FOUND 0, + SMALL_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, + __CTYPE_MULTIPART_ALT 0, __FROM_SAME_AS_TO2 0, __HAS_FROM 0, __HAS_HTML 0, + __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_HTML 0, __MIME_VERSION 0, + __MSGID_APPLEMAIL 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_START + 0, __TAG_EXISTS_HTML 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, + __USER_AGENT_APPLEMAIL 0, __X_MAILER_APPLEMAIL 0, __zen.spamhaus.org_ERROR ' +X-Pobox-Pass: rjbs@cpan.org is whitelisted +Lines: 19 + + +--Apple-Mail=_FAFF19B4-3BF3-4D29-930E-9D87CEC03F01 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=us-ascii + + +This is a multipart test. + +-- +rjbs +--Apple-Mail=_FAFF19B4-3BF3-4D29-930E-9D87CEC03F01 +Content-Transfer-Encoding: 7bit +Content-Type: text/html; + charset=us-ascii + +<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br> +This is a <b>multipart</b> test.<div><br></div><div>-- </div><div>rjbs</div></body></html> +--Apple-Mail=_FAFF19B4-3BF3-4D29-930E-9D87CEC03F01-- |