]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntp: delimit Newsgroup: header with commas
authorEric Wong <e@80x24.org>
Tue, 3 Nov 2020 22:55:59 +0000 (22:55 +0000)
committerEric Wong <e@80x24.org>
Wed, 4 Nov 2020 19:50:06 +0000 (19:50 +0000)
...instead of spaces.  This is specified in RFC 5536 3.1.4.

Include references to RFC 1036, 5536 and 5537 in our docs while
we're at it.

Reported-by: Andrey Melnikov <temnota.am@gmail.com>
Link: https://public-inbox.org/meta/CA+PODjpUN5Q4gBFQhAzUNuMasVEdmp9f=8Uo0Ej0mFumdSwi4w@mail.gmail.com/
Documentation/standards.perl
lib/PublicInbox/NNTP.pm

index 0ac6cc525efea8ef10acf28b4000a96b9db24219..1c56830e9b976c8d4aae1952a0a5c4820317e51e 100755 (executable)
@@ -25,6 +25,9 @@ EOF
 my $rfcs = [
        3977 => 'NNTP',
        977 => 'NNTP (old)',
+       1036 => 'Standard for Interchange of USENET Messages',
+       5536 => 'Netnews Article Format',
+       5537 => 'Netnews Architecture and Protocols',
        6048 => 'NNTP additions to LIST command (TODO)',
        8054 => 'NNTP compression',
        4642 => 'NNTP TLS',
index 102ef42cf4455d8e4035b288172f19d693f85901..783c0076e7d0771ba76f6a607be63f26c54ba80a 100644 (file)
@@ -432,12 +432,17 @@ sub set_nntp_headers ($$) {
                $hdr->header_set('X-Alt-Message-ID', @alt);
        }
 
-       # clobber some
+       # clobber some existing headers
        my $ibx = $smsg->{-ibx};
        my $xref = xref($smsg->{nntp}, $ibx, $smsg->{num}, $mid);
        $hdr->header_set('Xref', $xref);
-       $xref =~ s/:[0-9]+//g;
-       $hdr->header_set('Newsgroups', (split(/ /, $xref, 2))[1]);
+
+       # RFC 5536 3.1.4
+       my $newsgroups = (split(/ /, $xref, 2))[1]; # drop server name
+       $newsgroups =~ s/:[0-9]+\b//g; # drop NNTP article numbers
+       $newsgroups =~ tr/ /,/;
+       $hdr->header_set('Newsgroups', $newsgroups);
+
        header_append($hdr, 'List-Post', "<mailto:$ibx->{-primary_address}>");
        if (my $url = $ibx->base_url) {
                $mid = mid_escape($mid);