about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2018-04-01 22:58:19 +0000
committerEric Wong <e@80x24.org>2018-04-01 23:04:20 +0000
commit3f3d9cf7d88a851721f1f8468e1311a4f0c02ff6 (patch)
treecd42360b41e5e695c5f19802ec0147149b4e6e6d
parent051a182852a9eef8b0dc8714c81293daded1d4dc (diff)
downloadpublic-inbox-3f3d9cf7d88a851721f1f8468e1311a4f0c02ff6.tar.gz
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.
-rw-r--r--lib/PublicInbox/SearchView.pm6
-rw-r--r--t/psgi_search.t6
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index bf4415f0..219006a0 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -309,10 +309,8 @@ sub new {
         my ($class, $qp) = @_;
 
         my $r = $qp->{r};
-        my $l = $qp->{l} || '200';
-        if (! ($l =~ /(\d+)/ && $l <= $LIM)) {
-                $l = $LIM;
-        }
+        my ($l) = (($qp->{l} || '') =~ /(\d+)/);
+        $l = $LIM if !$l || $l > $LIM;
         bless {
                 q => $qp->{'q'},
                 x => $qp->{x} || '',
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 &#198;var Arnfj&#246;r&#240; 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();