From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6005363386F for ; Sat, 19 Sep 2015 02:03:47 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 12/12] nntp: article lookups by Message-ID may cross newsgroups Date: Sat, 19 Sep 2015 02:03:40 +0000 Message-Id: <20150919020340.6484-13-e@80x24.org> In-Reply-To: <20150919020340.6484-1-e@80x24.org> References: <20150919020340.6484-1-e@80x24.org> List-Id: Lynx seems to rely on this behavior for "ARTICLE " Tested with Lynx Version 2.8.8dev.12 (22 Feb 2012) on Debian wheezy. --- lib/PublicInbox/NNTP.pm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 80adb65..d513953 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -330,7 +330,7 @@ sub cmd_quit ($) { sub art_lookup ($$$) { my ($self, $art, $set_headers) = @_; - my $ng = $self->{ng} or return '412 no newsgroup has been selected'; + my $ng = $self->{ng}; my ($n, $mid); my $err; if (defined $art) { @@ -339,10 +339,18 @@ sub art_lookup ($$$) { $n = int($art); goto find_mid; } elsif ($art =~ /\A<([^>]+)>\z/) { - $err = '430 no such article found'; $mid = $1; - $n = $ng->mm->num_for($mid); - defined $mid or return $err; + $err = '430 no such article found'; + $n = $ng->mm->num_for($mid) if $ng; + goto found if defined $n; + foreach my $g (values %{$self->{nntpd}->{groups}}) { + $n = $g->mm->num_for($mid); + if (defined $n) { + $ng = $g; + goto found; + } + } + return $err; } else { return r501; } @@ -351,10 +359,11 @@ sub art_lookup ($$$) { $n = $self->{article}; defined $n or return $err; find_mid: + $ng or return '412 no newsgroup has been selected'; $mid = $ng->mm->mid_for($n); defined $mid or return $err; } - +found: my $o = 'HEAD:' . mid2path($mid); my $s = eval { Email::Simple->new($ng->gcf->cat_file($o)) }; return $err unless $s; -- EW