X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=lib%2FPublicInbox%2FSearchIdx.pm;h=06bce70a4218ba82e3d7e420131e6b58a30c6d16;hp=3412a615b66c3bdc2fd2897ad3c5ac6b2010287f;hb=2b6580afae0c0449fa536b62c8fbad4408337a3f;hpb=b8c41362f2a5c8fcc6b1846a79c72bfa77565297 diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 3412a615..06bce70a 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -334,7 +334,7 @@ sub add_message { }); # populates smsg->references for smsg->to_doc_data - my $refs = parse_references($smsg); + my $refs = parse_references($smsg, $mid0, $mids); my $data = $smsg->to_doc_data($oid, $mid0); foreach my $mid (@$mids) { $tg->index_text($mid, 1, 'XM'); @@ -463,22 +463,23 @@ sub term_generator { # write-only $self->{term_generator} = $tg; } -sub parse_references ($) { - my ($smsg) = @_; +sub parse_references ($$$) { + my ($smsg, $mid0, $mids) = @_; my $mime = $smsg->{mime}; my $hdr = $mime->header_obj; my $refs = references($hdr); + push(@$refs, @$mids) if scalar(@$mids) > 1; return $refs if scalar(@$refs) == 0; - # prevent circular references via References here: - my %mids = map { $_ => 1 } @{mids($hdr)}; + # prevent circular references here: + my %seen = ( $mid0 => 1 ); my @keep; foreach my $ref (@$refs) { if (length($ref) > PublicInbox::MID::MAX_MID_SIZE) { warn "References: <$ref> too long, ignoring\n"; next; } - next if $mids{$ref}; + next if $seen{$ref}++; push @keep, $ref; } $smsg->{references} = '<'.join('> <', @keep).'>' if @keep;