* [PATCH 6/7] nntp: XHDR fixes for Message-ID lookups
2015-09-22 10:09 7% [PATCH 0/7] nntp: another round of updates Eric Wong
@ 2015-09-22 10:09 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-09-22 10:09 UTC (permalink / raw)
To: meta
We'll require some modifications for HDR support, though.
---
lib/PublicInbox/NNTP.pm | 13 +++++++------
t/nntpd.t | 17 +++++++++++++++++
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 1286b70..c8ef01e 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -546,9 +546,10 @@ sub xhdr_message_id ($$) { # optimize XHDR Message-ID [range] for slrnpull.
my $mm = $self->{ng}->mm;
if (defined $range && $range =~ /\A<(.+)>\z/) { # Message-ID
- my $n = $mm->num_for($range);
+ my $n = $mm->num_for($1);
+ return '430 No article with that message-id' unless $n;
more($self, '221 Header follows');
- more($self, "<$range> <$range>") if defined $n;
+ more($self, "$range $range");
'.';
} else { # numeric range
$range = $self->{article} unless defined $range;
@@ -575,9 +576,9 @@ sub xhdr_xref ($$) { # optimize XHDR Xref [range] for rtin
my $ng = $self->{ng};
my $mm = $ng->mm;
if (defined $range && $range =~ /\A<(.+)>\z/) { # Message-ID
- my $n = $mm->num_for($range);
+ my $n = $mm->num_for($1);
more($self, '221 Header follows');
- more($self, "<$range> ".xref($ng, $n)) if defined $n;
+ more($self, "$range ".xref($ng, $n)) if defined $n;
'.';
} else { # numeric range
$range = $self->{article} unless defined $range;
@@ -655,12 +656,12 @@ sub cmd_xhdr ($$;$) {
sub xhdr_slow ($$$) {
my ($self, $header, $range) = @_;
- if (defined $range && $range =~ /\A<(.+)>\z/) { # Message-ID
+ if (defined $range && $range =~ /\A<.+>\z/) { # Message-ID
my $r = $self->art_lookup($range, 2);
return $r unless ref $r;
more($self, '221 Header follows');
if (defined($r = xhdr($r, $header))) {
- more($self, "<$range> $r");
+ more($self, "$range $r");
}
'.';
} else { # numeric range
diff --git a/t/nntpd.t b/t/nntpd.t
index d886e3c..090e150 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -95,6 +95,23 @@ EOF
is_deeply($list, { $group => [ qw(1 1 n) ] }, 'LIST works');
is_deeply([$n->group($group)], [ qw(0 1 1), $group ], 'GROUP works');
+ my $mid = '<nntp@example.com>';
+ my %xhdr = (
+ 'message-id' => $mid,
+ 'subject' => 'hihi',
+ 'date' => 'Thu, 01 Jan 1970 00:00:00 +0000',
+ 'from' => 'Me <me@example.com>',
+ 'to' => 'You <you@example.com>',
+ 'cc' => $addr,
+ 'xref' => "example.com $group:1"
+ );
+ while (my ($k, $v) = each %xhdr) {
+ is_deeply($n->xhdr("$k $mid"), { $mid => $v },
+ "$k by message-id works");
+ is_deeply($n->xhdr("$k 1"), { 1 => $v },
+ "$k by article number works");
+ }
+
# TODO: upgrades and such
ok(kill('TERM', $pid), 'killed nntpd');
--
EW
^ permalink raw reply related [relevance 6%]
* [PATCH 0/7] nntp: another round of updates
@ 2015-09-22 10:09 7% Eric Wong
2015-09-22 10:09 6% ` [PATCH 6/7] nntp: XHDR fixes for Message-ID lookups Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2015-09-22 10:09 UTC (permalink / raw)
To: meta
I guess we'll implement RFC 3977 before we commit to a extending
fields needed for an overview database...
Eric Wong (7):
t/nntpd.t: fix fcntl test to ensure no failures
nntp: support YYYYMMDD dates for commands
nntp: ensure body lines end with CRLF
nntp: avoid setting Bytes and Lines headers
nntp: implement OVER from RFC 3977
nntp: XHDR fixes for Message-ID lookups
nntp: XHDR lookups by Message-ID may cross groups
lib/PublicInbox/NNTP.pm | 136 ++++++++++++++++++++++++++++++++----------------
t/nntp.t | 29 +++++++++++
t/nntpd.t | 30 ++++++++++-
3 files changed, 147 insertions(+), 48 deletions(-)
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-09-22 10:09 7% [PATCH 0/7] nntp: another round of updates Eric Wong
2015-09-22 10:09 6% ` [PATCH 6/7] nntp: XHDR fixes for Message-ID lookups Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).