MANIFEST | 1 + t/msg_iter.t | 20 ++++++++++++++++++++ t/x-unknown-alpine.eml | 21 +++++++++++++++++++++ diff --git a/MANIFEST b/MANIFEST index 5acd8531b938fdf80ced8f6cda49c31785e4066e..48df274ea6b7880a967d89cde47e59e081886a64 100644 --- a/MANIFEST +++ b/MANIFEST @@ -299,6 +299,7 @@ t/watch_maildir.t t/watch_maildir_v2.t t/www_listing.t t/www_static.t +t/x-unknown-alpine.eml t/xcpdb-reshard.t xt/git-http-backend.t xt/git_async_cmp.t diff --git a/t/msg_iter.t b/t/msg_iter.t index de9c39fa6742d9b7dff39029be556ca0e3fad55d..e33bfc69df1bcc2d0b00d16424e3f70993d9d419 100644 --- a/t/msg_iter.t +++ b/t/msg_iter.t @@ -4,6 +4,7 @@ use strict; use warnings; use Test::More; use Email::MIME; +use PublicInbox::Hval qw(ascii_html); use_ok('PublicInbox::MsgIter'); { @@ -56,6 +57,25 @@ $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(); diff --git a/t/x-unknown-alpine.eml b/t/x-unknown-alpine.eml new file mode 100644 index 0000000000000000000000000000000000000000..75b0bc55a5ed57f1d43787d3302440efd7d6d74e --- /dev/null +++ b/t/x-unknown-alpine.eml @@ -0,0 +1,21 @@ +Date: Sat, 13 Aug 2016 12:14:15 +0200 (CEST) +From: Alpine User +To: +Subject: charset=X-UNKNOWN test +Message-ID: +User-Agent: Alpine 2.20 (DEB 67 2015-01-07) +MIME-Version: 1.0 +Content-Type: multipart/mixed; BOUNDARY="8323329-703494712-1471083256=:4924" + + This message is in MIME format. The first part should be readable text, + while the remaining parts are likely unreadable without MIME-aware tools. + +--8323329-703494712-1471083256=:4924 +Content-Type: text/plain; charset=X-UNKNOWN +Content-Transfer-Encoding: QUOTED-PRINTABLE + +=09https://example.com/ + + =E2=80=A2 bullet point + +--8323329-703494712-1471083256=:4924--