From: Eric Wong <e@yhbt.net>
To: spew@80x24.org
Subject: [PATCH 2/2] WIP
Date: Tue, 31 Mar 2020 06:42:33 +0000 [thread overview]
Message-ID: <20200331064233.30017-2-e@yhbt.net> (raw)
In-Reply-To: <20200331064233.30017-1-e@yhbt.net>
---
lib/PublicInbox/NNTP.pm | 25 +++++++++++++++++++++----
t/v2writable.t | 3 ---
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 277657e6..1de0b84d 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -78,11 +78,28 @@ sub process_line ($$) {
my ($self, $l) = @_;
my ($req, @args) = split(/[ \t]/, $l);
return 1 unless defined($req); # skip blank line
- $req = $self->can('cmd_'.lc($req));
- return res($self, '500 command not recognized') unless $req;
- return res($self, r501) unless args_ok($req, scalar @args);
+ my $cmd = $self->can('cmd_'.lc($req));
+ return res($self, '500 command not recognized') unless $cmd;
+ unless (args_ok($cmd, scalar @args)) {
+ # check for Message-IDs with spaces
+ open DBG, '>>', '/tmp/dbg';
+ DBG->autoflush(1);
+ use Data::Dumper; print DBG Dumper([$req, \@args, $l]);
+ if ($req =~ /\A(?:article|head|body|over|stat)\z/i) {
+ my (undef, $mid) = split(/[ \t]/, $l, 2);
+ return res($self, r501) if $mid !~ /\A<[^>]+>\z/;
+ @args = $mid;
+ } elsif ($req =~ /\A(?:hdr|xhdr)\z/i && scalar(@args) > 2) {
+ my (undef, $fld, $mid) = split(/[ \t]/, $l, 3);
+ return res($self, r501) if $mid !~ /\A<[^>]+>\z/;
+ @args = ($fld, $mid);
+ use Data::Dumper; print DBG Dumper([$fld, $mid]);
+ } else {
+ return res($self, r501);
+ }
+ }
- my $res = eval { $req->($self, @args) };
+ my $res = eval { $cmd->($self, @args) };
my $err = $@;
if ($err && $self->{sock}) {
local $/ = "\n";
diff --git a/t/v2writable.t b/t/v2writable.t
index 8167e4de..be15e353 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -181,9 +181,6 @@ EOF
is_deeply($n->xhdr('Message-ID', $num),
{ $num => $mid }, "XHDR lookup OK on num $num");
- # FIXME NNTP.pm doesn't handle spaces in Message-ID
- next if $mid =~ / /;
-
is_deeply($n->xhdr('Message-ID', $mid),
{ $mid => $mid }, "XHDR lookup OK on MID $mid ($num)");
}
next prev parent reply other threads:[~2020-03-31 6:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-31 6:42 [PATCH 1/2] v2writable: index Message-IDs w/ spaces properly Eric Wong
2020-03-31 6:42 ` Eric Wong [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-05-13 22:16 [PATCH 1/2] search: add comments wrt codesearch, reduce ops Eric Wong
2023-05-13 22:16 ` [PATCH 2/2] WIP Eric Wong
2023-05-04 11:07 [PATCH 1/2] reuse open(2) from rb_file_load_ok on POSIX-like system Eric Wong
2023-05-04 11:07 ` [PATCH 2/2] wip Eric Wong
2023-04-17 23:06 [PATCH 1/2] reuse open(2) from rb_file_load_ok on POSIX-like system Eric Wong
2023-04-17 23:06 ` [PATCH 2/2] wip Eric Wong
2021-01-15 10:24 [PATCH 1/2] lei_to_mail: prepare Eric Wong
2021-01-15 10:24 ` [PATCH 2/2] wip Eric Wong
2019-11-03 3:17 [PATCH 1/2] edit: hoist out prompt functions into sub functions Eric Wong
2019-11-03 3:17 ` [PATCH 2/2] wip Eric Wong
2019-09-23 3:16 [PATCH 1/2] edit: hoist out prompt functions into sub functions ew
2019-09-23 3:16 ` [PATCH 2/2] wip ew
2019-01-07 8:02 [PATCH 1/2] hoist out resolve_repo_dir from -index Eric Wong
2019-01-07 8:02 ` [PATCH 2/2] wip Eric Wong
2018-09-09 8:35 [PATCH 1/2] cont.c (fiber_memsize): do not rely on ROOT_FIBER_CONTEXT Eric Wong
2018-09-09 8:35 ` [PATCH 2/2] wip Eric Wong
2018-09-09 8:00 [PATCH 1/2] test_fiber: show crash on GC after forking Eric Wong
2018-09-09 8:00 ` [PATCH 2/2] wip Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200331064233.30017-2-e@yhbt.net \
--to=e@yhbt.net \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).