2 # Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
7 use PublicInbox::ContentHash qw(content_hash);
10 my $mime = PublicInbox::Eml->new(<<'EOF');
13 Subject: this is a subject
14 Message-ID: <a@example.com>
15 Date: Fri, 02 Oct 1993 00:00:00 +0000
20 my $orig = content_hash($mime);
21 my $reload = content_hash(PublicInbox::Eml->new($mime->as_string));
22 is($orig, $reload, 'content_hash matches after serialization');
24 my $s1 = PublicInbox::Eml->new($mime->as_string);
25 $s1->header_set('Sender', 's@example.com');
26 is(content_hash($s1), $orig, "Sender ignored when 'From' present");
27 my $s2 = PublicInbox::Eml->new($s1->as_string);
28 $s1->header_set('Sender', 'sender@example.com');
29 is(content_hash($s2), $orig, "Sender really ignored 'From'");
30 $_->header_set('From') for ($s1, $s2);
31 isnt(content_hash($s1), content_hash($s2),
32 'sender accounted when From missing');
35 foreach my $h (qw(From To Cc)) {
36 my $n = q("Quoted N'Ame" <foo@EXAMPLE.com>);
37 $mime->header_set($h, "$n");
38 my $q = content_hash($mime);
39 is($mime->header($h), $n, "content_hash does not mutate $h:");
40 $mime->header_set($h, 'Quoted N\'Ame <foo@example.com>');
41 my $nq = content_hash($mime);
42 is($nq, $q, "quotes ignored in $h:");