about summary refs log tree commit
path: root/t/msg_iter.t
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-02-14 07:05:22 +0000
committerEric Wong <e@yhbt.net>2020-02-15 08:19:40 +0000
commit6940f5c8a8436a7a5c846d2079b9d8588872459f (patch)
treea0d93c291931aed8f73c7b3580c839bf4d3d03a0 /t/msg_iter.t
parent9099c07f7bd99231ba13e43b0f2bbc8c9a2d53b2 (diff)
downloadpublic-inbox-6940f5c8a8436a7a5c846d2079b9d8588872459f.tar.gz
A long overdue test for behavior established in 2016.

Fixes: 1b28cc7f00a866cb ("view: try assuming UTF-8 for bogus charsets")
Diffstat (limited to 't/msg_iter.t')
-rw-r--r--t/msg_iter.t20
1 files changed, 20 insertions, 0 deletions
diff --git a/t/msg_iter.t b/t/msg_iter.t
index de9c39fa..e33bfc69 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');
 
 {
@@ -58,5 +59,24 @@ use_ok('PublicInbox::MsgIter');
         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/&#8226; bullet point/s,
+                'got bullet point when X-UNKNOWN assumes UTF-8');
+}
+
 done_testing();
 1;