1 # Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
7 use PublicInbox::Hval qw(ascii_html);
8 use_ok('PublicInbox::MsgIter');
11 my $parts = [ Email::MIME->create(body => "a\n"),
12 Email::MIME->create(body => "b\n") ];
13 my $mime = Email::MIME->create(parts => $parts,
14 header_str => [ From => 'root@localhost' ]);
17 my ($part, $level, @ex) = @{$_[0]};
18 my $s = $part->body_str;
20 push @parts, [ $s, $level, @ex ];
22 is_deeply(\@parts, [ [ qw(a 1 1) ], [ qw(b 1 2) ] ], 'order is fine');
26 my $parts = [ Email::MIME->create(body => 'a'),
27 Email::MIME->create(body => 'b') ];
28 $parts = [ Email::MIME->create(parts => $parts,
29 header_str => [ From => 'sub@localhost' ]),
30 Email::MIME->create(body => 'sig') ];
31 my $mime = Email::MIME->create(parts => $parts,
32 header_str => [ From => 'root@localhost' ]);
35 my ($part, $level, @ex) = @{$_[0]};
36 my $s = $part->body_str;
38 push @parts, [ $s, $level, @ex ];
40 is_deeply(\@parts, [ [qw(a 2 1 1)], [qw(b 2 1 2)], [qw(sig 1 2)] ],
41 'nested part shows up properly');
45 my $f = 't/iso-2202-jp.mbox';
46 my $mime = Email::MIME->new(do {
47 open my $fh, '<', $f or die "open($f): $!";
53 my ($part, $level, @ex) = @{$_[0]};
54 my ($s, $err) = msg_part_text($part, 'text/plain');
55 ok(!$err, 'no error');
58 ok(length($raw) > 0, 'got non-empty message');
59 is(index($raw, '$$$'), -1, 'no unescaped $$$');
63 my $f = 't/x-unknown-alpine.eml';
64 my $mime = Email::MIME->new(do {
65 open my $fh, '<', $f or die "open($f): $!";
72 my ($part, $level, @ex) = @{$_[0]};
73 my ($s, $err) = msg_part_text($part, 'text/plain');
76 like($raw, qr!^\thttps://!ms, 'tab expanded with X-UNKNOWN');
77 like(ascii_html($raw), qr/• bullet point/s,
78 'got bullet point when X-UNKNOWN assumes UTF-8');