1 # Copyright (C) 2018-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::ContentId qw(content_id);
9 my $mime = Email::MIME->create(
11 From => 'a@example.com',
12 To => 'b@example.com',
13 'Content-Type' => 'text/plain',
14 Subject => 'this is a subject',
15 'Message-ID' => '<a@example.com>',
16 Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
18 body => "hello world\n",
21 my $orig = content_id($mime);
22 my $reload = content_id(Email::MIME->new($mime->as_string));
23 is($orig, $reload, 'content_id matches after serialization');
25 foreach my $h (qw(From To Cc)) {
26 my $n = q("Quoted N'Ame" <foo@EXAMPLE.com>);
27 $mime->header_set($h, "$n");
28 my $q = content_id($mime);
29 is($mime->header($h), $n, "content_id does not mutate $h:");
30 $mime->header_set($h, 'Quoted N\'Ame <foo@example.com>');
31 my $nq = content_id($mime);
32 is($nq, $q, "quotes ignored in $h:");