]> Sergey Matveev's repositories - public-inbox.git/commitdiff
search_query: fix warnings on empty "o=" query
authorEric Wong <e@80x24.org>
Wed, 14 Dec 2022 22:24:08 +0000 (22:24 +0000)
committerEric Wong <e@80x24.org>
Thu, 15 Dec 2022 00:16:41 +0000 (00:16 +0000)
This fixes the following warnings from bad URLs:

  Odd number of elements in anonymous hash at <>/PublicInbox/SearchQuery.pm line 22.
  Argument "l" isn't numeric in numeric lt (<) at <>/PublicInbox/SearchView.pm line 39.

lib/PublicInbox/SearchQuery.pm

index a6b7d8430b194ae7ff9be291928461fbae218e8c..96246c5385d8c0ca8fcc18191be2b4e1b34d71a2 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # used by PublicInbox::SearchView and PublicInbox::WwwListing
@@ -16,10 +16,11 @@ sub new {
        my $t = $qp->{t}; # collapse threads
        my ($l) = (($qp->{l} || '') =~ /([0-9]+)/);
        $l = $LIM if !$l || $l > $LIM;
+       my ($o) = (($qp->{o} || '0') =~ /(-?[0-9]+)/);
        bless {
                q => $qp->{'q'},
                x => $qp->{x} || '',
-               o => (($qp->{o} || '0') =~ /(-?[0-9]+)/),
+               o => $o,
                l => $l,
                r => (defined $r && $r ne '0'),
                t => (defined $t && $t ne '0'),