]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: deal with empty In-Reply-To and References headers
authorEric Wong <e@80x24.org>
Mon, 6 Feb 2017 19:54:25 +0000 (19:54 +0000)
committerEric Wong <e@80x24.org>
Mon, 6 Feb 2017 19:55:29 +0000 (19:55 +0000)
In some messages, these headers exist, but have empty values.
Do not let empty values throw off our search indexer to tie
threads together, as it can make non-sensical threads grouped
to a Message-Id of "" (empty string).

See
<https://public-inbox.org/git/11340844841342-git-send-email-mailing-lists.git@rawuncut.elitemail.org/raw>
for an example of such a message.

Thanks-to: Johannes Schindelin <Johannes.Schindelin@gmx.de>
  <https://public-inbox.org/git/alpine.DEB.2.20.1702041206130.3496@virtualbox/>

lib/PublicInbox/SearchIdx.pm

index d63dd7c742b4c21ef9420d810954df3e8332f45e..1142ca7a0f4c83a6aa4103edc79d91bd04944e5a 100644 (file)
@@ -292,11 +292,15 @@ sub link_message {
        my $mime = $smsg->{mime};
        my $hdr = $mime->header_obj;
        my $refs = $hdr->header_raw('References');
        my $mime = $smsg->{mime};
        my $hdr = $mime->header_obj;
        my $refs = $hdr->header_raw('References');
-       my @refs = $refs ? ($refs =~ /<([^>]+)>/g) : ();
+       my @refs = defined $refs ? ($refs =~ /<([^>]+)>/g) : ();
        my $irt = $hdr->header_raw('In-Reply-To');
        if (defined $irt) {
        my $irt = $hdr->header_raw('In-Reply-To');
        if (defined $irt) {
-               $irt = mid_clean($irt);
-               $irt = undef if $mid eq $irt;
+               if ($irt eq '') {
+                       $irt = undef;
+               } else {
+                       $irt = mid_clean($irt);
+                       $irt = undef if $mid eq $irt;
+               }
        }
 
        my $tid;
        }
 
        my $tid;