-# Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# Unstable internal API.
# do NOT consider the Message-ID as part of the content_hash
# if we got here, we've already got Message-ID reuse
my %seen = map { $_ => 1 } @{mids($eml)};
- foreach my $mid (@{references($eml)}) {
- $dig->add("ref\0$mid\0") unless $seen{$mid}++;
+ for (grep { !$seen{$_}++ } @{references($eml)}) {
+ utf8::encode($_);
+ $dig->add("ref\0$_\0");
}
# Only use Sender: if From is not present
is($msgs->[1]->{mid}, 'y'x244, 'stored truncated mid(2)');
}
+if ('UTF-8 References') {
+ my @w;
+ local $SIG{__WARN__} = sub { push @w, @_ };
+ my $msg = <<EOM;
+From: a\@example.com
+Subject: b
+Message-ID: <horrible\@example>
+References: <\xc4\x80\@example>
+
+EOM
+ ok($im->add(PublicInbox::Eml->new($msg."a\n")), 'UTF-8 References 1');
+ ok($im->add(PublicInbox::Eml->new($msg."b\n")), 'UTF-8 References 2');
+ $im->done;
+ ok(!grep(/Wide character/, @w), 'no wide characters') or xbail(\@w);
+}
+
my $tmp = {
inboxdir => "$inboxdir/non-existent/subdir",
name => 'nope',