diff options
author | Eric Wong <e@80x24.org> | 2019-06-14 00:27:31 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-06-14 00:27:31 +0000 |
commit | 541103582a3f60a3c6df0383382cacd782ea1edd (patch) | |
tree | d336f561fe43ccc831a8a57718f0a8a4efdfb62f /lib/PublicInbox/NNTP.pm | |
parent | 4b8b3036ba08515eb66fb014b6ded9dc57e079b2 (diff) | |
download | public-inbox-541103582a3f60a3c6df0383382cacd782ea1edd.tar.gz |
It's the unfortunate reality that there are some clients which reuse Message-IDs (in which we generate + use another) or set multiple Message-IDs on their own. While the v2 format addresses that, NNTP clients such as leafnode are not always prepared to deal with that case. So, ensure NNTP clients only see a single Message-ID, and show the others as 'X-Alt-Message-ID'.
Diffstat (limited to 'lib/PublicInbox/NNTP.pm')
-rw-r--r-- | lib/PublicInbox/NNTP.pm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index d409e782..8a31b910 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -438,6 +438,22 @@ sub set_nntp_headers ($$$$$) { # reason. We'll fake the shortest one possible. $hdr->header_set('Path', 'y'); + # leafnode (and maybe other NNTP clients) have trouble dealing + # with v2 messages which have multiple Message-IDs (either due + # to our own content-based dedupe or buggy git-send-email versions). + my @mids = $hdr->header('Message-ID'); + if (scalar(@mids) > 1) { + my $mid0 = "<$mid>"; + $hdr->header_set('Message-ID', $mid0); + my @alt = $hdr->header('X-Alt-Message-ID'); + my %seen = map { $_ => 1 } (@alt, $mid0); + foreach my $m (@mids) { + next if $seen{$m}++; + push @alt, $m; + } + $hdr->header_set('X-Alt-Message-ID', @alt); + } + # clobber some my $xref = xref($self, $ng, $n, $mid); $hdr->header_set('Xref', $xref); |