From 3f3d9cf7d88a851721f1f8468e1311a4f0c02ff6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 1 Apr 2018 22:58:19 +0000 Subject: searchview: fix non-numeric comparison We don't want non-fully-numeric limits being compared and tripping warnings. While we're at it, avoid hard-coding '200' and reuse $LIM as the default. --- t/psgi_search.t | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 't') diff --git a/t/psgi_search.t b/t/psgi_search.t index 1df38691..84b3daa3 100644 --- a/t/psgi_search.t +++ b/t/psgi_search.t @@ -64,6 +64,12 @@ test_psgi(sub { $www->call(@_) }, sub { is('%C3%86var', (keys %uniq)[0], 'matches original query'); ok(index($html, 'by Ævar Arnfjörð Bjarmason') >= 0, "displayed Ævar's name properly in HTML"); + + my $warn = []; + local $SIG{__WARN__} = sub { push @$warn, @_ }; + $res = $cb->(GET('/test/?q=s:test&l=5e')); + is($res->code, 200, 'successful search result'); + is_deeply([], $warn, 'no warnings from non-numeric comparison'); }); done_testing(); -- cgit v1.2.3-24-ge0c7 From 4f0b09919ae9c8823bf6c1fa1452bc27945952a3 Mon Sep 17 00:00:00 2001 From: "Eric Wong (Contractor, The Linux Foundation)" Date: Sat, 3 Mar 2018 20:18:34 +0000 Subject: nntp: fix NEWNEWS command I guess nobody uses this command (slrnpull does not), and the breakage was not noticed until I started writing new tests for multi-MID handling. Fixes: 3fc411c772a21d8f ("search: drop pointless range processors for Unix timestamp") --- t/nntpd.t | 2 ++ 1 file changed, 2 insertions(+) (limited to 't') diff --git a/t/nntpd.t b/t/nntpd.t index 56b1d604..2815d8d6 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -204,6 +204,8 @@ EOF is_deeply($n->xhdr(qw(list-id 1-)), {}, 'XHDR on invalid header returns empty'); + my $mids = $n->newnews(0, '*'); + is_deeply($mids, [''], 'NEWNEWS works'); { my $t0 = time; my $date = $n->date; -- cgit v1.2.3-24-ge0c7 From 15eb65ffd59c7cf5cce67c6b7621f63194fd1083 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 3 Apr 2018 10:34:54 +0000 Subject: mbox: do not barf on queries which return no results Having zero search results means we never get a chance to populate the Content-Disposition header for mbox downloads. --- t/psgi_search.t | 4 ++++ 1 file changed, 4 insertions(+) (limited to 't') diff --git a/t/psgi_search.t b/t/psgi_search.t index 84b3daa3..cf5a7e91 100644 --- a/t/psgi_search.t +++ b/t/psgi_search.t @@ -70,6 +70,10 @@ test_psgi(sub { $www->call(@_) }, sub { $res = $cb->(GET('/test/?q=s:test&l=5e')); is($res->code, 200, 'successful search result'); is_deeply([], $warn, 'no warnings from non-numeric comparison'); + + $res = $cb->(POST('/test/?q=s:bogus&x=m')); + is($res->code, 404, 'failed search result gives 404'); + is_deeply([], $warn, 'no warnings'); }); done_testing(); -- cgit v1.2.3-24-ge0c7 From 119463b3b8517e5ec149198bb83588999118ee1d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 18 Apr 2018 20:30:22 +0000 Subject: nntp: allow and ignore empty commands Somebody hitting "\n" into telnet shouldn't hold a client up indefinitely and prevent shutdown. --- t/nntpd.t | 2 ++ 1 file changed, 2 insertions(+) (limited to 't') diff --git a/t/nntpd.t b/t/nntpd.t index 2815d8d6..20191cb6 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -122,6 +122,8 @@ EOF is($buf, "201 server ready - post via email\r\n", 'got greeting'); $s->autoflush(1); + ok(syswrite($s, " \r\n"), 'wrote spaces'); + ok(syswrite($s, "\r\n"), 'wrote nothing'); syswrite($s, "NEWGROUPS\t19990424 000000 \033GMT\007\r\n"); is(0, sysread($s, $buf, 4096), 'GOT EOF on cntrl'); -- cgit v1.2.3-24-ge0c7