]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntp: fix LIST OVERVIEW.FMT ordering and format
authorEric Wong <e@80x24.org>
Sat, 13 Jul 2019 21:38:11 +0000 (21:38 +0000)
committerEric Wong <e@80x24.org>
Sat, 13 Jul 2019 21:49:42 +0000 (21:49 +0000)
RFC3977 8.4.2 mandates the order of non-standard headers
to be after the first seven standard headers/metadata;
so "Xref:" must appear after "Lines:"|":lines".

Additionally, non-required header names must be followed
by ":full".

Cc: Jonathan Corbet <corbet@lwn.net>
Reported-by: Urs Janßen
<E1hmKBw-0008Bq-8t@akw>

lib/PublicInbox/NNTP.pm
t/nntpd.t

index 0d2bc4f33d8b46f471e12b8fcaf3d17074bf4533..800ce9265268eec77b240acfee66ecb82c74ca99 100644 (file)
@@ -29,8 +29,9 @@ use constant {
 use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);
 use Errno qw(EAGAIN);
 
-my @OVERVIEW = qw(Subject From Date Message-ID References Xref);
-my $OVERVIEW_FMT = join(":\r\n", @OVERVIEW, qw(Bytes Lines)) . ":\r\n";
+my @OVERVIEW = qw(Subject From Date Message-ID References);
+my $OVERVIEW_FMT = join(":\r\n", @OVERVIEW, qw(Bytes Lines), '') .
+               "Xref:full\r\n";
 my $LIST_HEADERS = join("\r\n", @OVERVIEW,
                        qw(:bytes :lines Xref To Cc)) . "\r\n";
 my $CAPABILITIES = <<"";
index e264fa6b5abbbfe255291b22670cc6952fdb3d94..bebecc6920d947939f644bae675123fcd1b3f4c3 100644 (file)
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -101,6 +101,12 @@ EOF
        is_deeply([$n->group($group)], [ qw(0 1 1), $group ], 'GROUP works');
        is_deeply($n->listgroup($group), [1], 'listgroup OK');
 
+       {
+               my $expect = [ qw(Subject: From: Date: Message-ID:
+                               References: Bytes: Lines: Xref:full) ];
+               is_deeply($n->overview_fmt, $expect,
+                       'RFC3977 8.4.2 compliant LIST OVERVIEW.FMT');
+       }
        SKIP: {
                $n->can('starttls') or
                        skip('Net::NNTP too old to support STARTTLS', 2);