user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 3/3] www: do not warn on blank query parameters
  2021-06-23 11:14  5% [PATCH 0/3] some WWW search things Eric Wong
@ 2021-06-23 11:14  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-06-23 11:14 UTC (permalink / raw)
  To: meta

Sometimes users (or bots) may lead queries with '&' and
trigger uninitialized variable warnings, just ignore them
and give consumers a $ctx->{qp}->{''} entry.

While we're in the area, pass a regexp rather than scalar string
to the `split' perlop to prevent Perl from recompiling the
regexp on every call.
---
 lib/PublicInbox/WWW.pm | 5 ++---
 t/psgi_search.t        | 4 ++++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 8f4bfd0f..841a7e85 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -50,10 +50,9 @@ sub call {
 	%{$ctx->{qp}} = map {
 		utf8::decode($_);
 		tr/+/ /;
-		my ($k, $v) = split('=', $_, 2);
-		$v = uri_unescape($v // '');
+		my ($k, $v) = split(/=/, $_, 2);
 		# none of the keys we care about will need escaping
-		$k => $v;
+		($k // '', uri_unescape($v // ''))
 	} split(/[&;]+/, $env->{QUERY_STRING});
 
 	my $path_info = path_info_raw($env);
diff --git a/t/psgi_search.t b/t/psgi_search.t
index d59e439b..5bdd66ed 100644
--- a/t/psgi_search.t
+++ b/t/psgi_search.t
@@ -88,6 +88,10 @@ test_psgi(sub { $www->call(@_) }, sub {
 	is($res->code, 200, 'successful search result');
 	is_deeply([], $warn, 'no warnings from non-numeric comparison');
 
+	$res = $cb->(GET('/test/?&q=s:test'));
+	is($res->code, 200, 'successful search result');
+	is_deeply([], $warn, 'no warnings from black parameter');
+
 	$res = $cb->(POST('/test/?q=s:bogus&x=m'));
 	is($res->code, 404, 'failed search result gives 404');
 	is_deeply([], $warn, 'no warnings');

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/3] some WWW search things
@ 2021-06-23 11:14  5% Eric Wong
  2021-06-23 11:14  7% ` [PATCH 3/3] www: do not warn on blank query parameters Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-06-23 11:14 UTC (permalink / raw)
  To: meta

Needed a break from banging my head trying to deal with
lei multi-directional sync semantics (while dealing with
the summertime heat and bug infestations :<)

www_listing ought to be faster when dealing with many inboxes,
more to come on that front.

Eric Wong (3):
  search: make xap_terms easier-to-use and use it more
  www_listing: start updating for pagination + search
  www: do not warn on blank query parameters

 lib/PublicInbox/Config.pm       |   5 ++
 lib/PublicInbox/LeiSearch.pm    |  16 ++--
 lib/PublicInbox/LeiXSearch.pm   |   4 +-
 lib/PublicInbox/ManifestJsGz.pm |   2 +-
 lib/PublicInbox/MiscSearch.pm   |  57 ++++++------
 lib/PublicInbox/Search.pm       |  22 ++---
 lib/PublicInbox/SearchIdx.pm    |   5 +-
 lib/PublicInbox/SearchQuery.pm  |  13 +--
 lib/PublicInbox/SearchView.pm   |   2 +-
 lib/PublicInbox/WWW.pm          |   5 +-
 lib/PublicInbox/WwwListing.pm   | 155 +++++++++++++++++++++++++++-----
 t/lei_store.t                   |   3 +-
 t/psgi_search.t                 |   4 +
 13 files changed, 200 insertions(+), 93 deletions(-)

^ permalink raw reply	[relevance 5%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-06-23 11:14  5% [PATCH 0/3] some WWW search things Eric Wong
2021-06-23 11:14  7% ` [PATCH 3/3] www: do not warn on blank query parameters Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).