X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fmsg_iter.t;h=e33bfc69df1bcc2d0b00d16424e3f70993d9d419;hb=2fc67a18b7ccd75ea6eb945f18203cbf4bcf228f;hp=c1798cb7f9430200ce97e6552a5c8b1179f415d2;hpb=3d41aa23f35501ca92aab8aa42980fa73f7fa74f;p=public-inbox.git diff --git a/t/msg_iter.t b/t/msg_iter.t index c1798cb7..e33bfc69 100644 --- a/t/msg_iter.t +++ b/t/msg_iter.t @@ -1,9 +1,10 @@ -# Copyright (C) 2016-2018 all contributors +# Copyright (C) 2016-2020 all contributors # License: AGPL-3.0+ use strict; use warnings; use Test::More; use Email::MIME; +use PublicInbox::Hval qw(ascii_html); use_ok('PublicInbox::MsgIter'); { @@ -40,5 +41,42 @@ use_ok('PublicInbox::MsgIter'); 'nested part shows up properly'); } +{ + my $f = 't/iso-2202-jp.mbox'; + my $mime = Email::MIME->new(do { + open my $fh, '<', $f or die "open($f): $!"; + local $/; + <$fh>; + }); + my $raw = ''; + msg_iter($mime, sub { + my ($part, $level, @ex) = @{$_[0]}; + my ($s, $err) = msg_part_text($part, 'text/plain'); + ok(!$err, 'no error'); + $raw .= $s; + }); + ok(length($raw) > 0, 'got non-empty message'); + is(index($raw, '$$$'), -1, 'no unescaped $$$'); +} + +{ + my $f = 't/x-unknown-alpine.eml'; + my $mime = Email::MIME->new(do { + open my $fh, '<', $f or die "open($f): $!"; + local $/; + binmode $fh; + <$fh>; + }); + my $raw = ''; + msg_iter($mime, sub { + my ($part, $level, @ex) = @{$_[0]}; + my ($s, $err) = msg_part_text($part, 'text/plain'); + $raw .= $s; + }); + like($raw, qr!^\thttps://!ms, 'tab expanded with X-UNKNOWN'); + like(ascii_html($raw), qr/• bullet point/s, + 'got bullet point when X-UNKNOWN assumes UTF-8'); +} + done_testing(); 1;