]> Sergey Matveev's repositories - public-inbox.git/commitdiff
content_id: use Sender header if From is not available
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Mon, 19 Mar 2018 08:14:33 +0000 (08:14 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Mon, 19 Mar 2018 08:16:34 +0000 (08:16 +0000)
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")
lib/PublicInbox/ContentId.pm

index 8347de2d2846654ef2042c4d34aa6d4595e92dc1..9082b7694002168467ab3d2610a36631348116d2 100644 (file)
@@ -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;
        }