From: Eric Wong (Contractor, The Linux Foundation) Date: Mon, 19 Mar 2018 08:14:33 +0000 (+0000) Subject: content_id: use Sender header if From is not available X-Git-Tag: v1.1.0-pre1~169 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=dd83a896a7eb718dcd49560d0aab967f1f481883 content_id: use Sender header if From is not available We will be using Sender: in more places if the From: header is not available, this is one of them. Followup-to: ("import: fall back to Sender for extracting name and email") --- diff --git a/lib/PublicInbox/ContentId.pm b/lib/PublicInbox/ContentId.pm index 8347de2d..9082b769 100644 --- a/lib/PublicInbox/ContentId.pm +++ b/lib/PublicInbox/ContentId.pm @@ -11,9 +11,6 @@ use PublicInbox::MID qw(mids references); # not sure if less-widely supported hash families are worth bothering with use Digest::SHA; -# Content-* headers are often no-ops, so maybe we don't need them -my @ID_HEADERS = qw(Subject From Date To Cc); - sub content_digest ($) { my ($mime) = @_; my $dig = Digest::SHA->new(256); @@ -31,7 +28,18 @@ sub content_digest ($) { next if $seen{$mid}; $dig->add('ref: '.$mid); } - foreach my $h (@ID_HEADERS) { + + # Only use Sender: if From is not present + foreach my $h (qw(From Sender)) { + my @v = $hdr->header_raw($h); + if (@v) { + $dig->add("$h: $_") foreach @v; + last; + } + } + + # Content-* headers are often no-ops, so maybe we don't need them + foreach my $h (qw(Subject Date To Cc)) { my @v = $hdr->header_raw($h); $dig->add("$h: $_") foreach @v; }