X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FSearchIdx.pm;h=fd0d320e8685fe34c37b5f07162d3e81da2f0c06;hb=1c9be46742295e943f7d919ee01ecbf134cbf493;hp=1142ca7a0f4c83a6aa4103edc79d91bd04944e5a;hpb=83425ef12e4b65cdcecd11ddcb38175d4a91d5a0;p=public-inbox.git diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 1142ca7a..fd0d320e 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -291,17 +291,12 @@ sub link_message { my $mid = $smsg->mid; my $mime = $smsg->{mime}; my $hdr = $mime->header_obj; - my $refs = $hdr->header_raw('References'); - my @refs = defined $refs ? ($refs =~ /<([^>]+)>/g) : (); - my $irt = $hdr->header_raw('In-Reply-To'); - if (defined $irt) { - if ($irt eq '') { - $irt = undef; - } else { - $irt = mid_clean($irt); - $irt = undef if $mid eq $irt; - } - } + + # last References should be IRT, but some mail clients do things + # out of order, so trust IRT over References iff IRT exists + my @refs = ($hdr->header_raw('References'), + $hdr->header_raw('In-Reply-To')); + @refs = ((join(' ', @refs)) =~ /<([^>]+)>/g); my $tid; if (@refs) { @@ -309,15 +304,6 @@ sub link_message { my @orig_refs = @refs; @refs = (); - if (defined $irt) { - # to check MAX_MID_SIZE - push @orig_refs, $irt; - - # below, we will ensure IRT (if specified) - # is the last References - $uniq{$irt} = 1; - } - # prevent circular references via References: here: foreach my $ref (@orig_refs) { if (length($ref) > MAX_MID_SIZE) { @@ -329,10 +315,6 @@ sub link_message { } } - # last References should be IRT, but some mail clients do things - # out of order, so trust IRT over References iff IRT exists - push @refs, $irt if defined $irt; - if (@refs) { $smsg->{references} = '<'.join('> <', @refs).'>'; @@ -348,7 +330,7 @@ sub link_message { merge_threads($self, $tid, $ptid); } } else { - $tid = $self->next_thread_id; + $tid = defined $old_tid ? $old_tid : $self->next_thread_id; } $doc->add_term(xpfx('thread') . $tid); } @@ -638,7 +620,7 @@ sub with_umask { my $rv = eval { $cb->() }; my $err = $@; umask $old; - die $err if $@; + die $err if $err; $rv; }