* [PATCH 4/4] lei q: make HTTP(S) query strings even less ugly
@ 2021-11-10 10:28 6% ` Eric Wong
0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2021-11-10 10:28 UTC (permalink / raw)
To: meta
Following commit 57fed2e4b78ed394 (lei: normalize whitespace in
remote queries, 2021-09-11), leaving the trailing `\n' from
stdin queries to be normalized to ` ' (SP) causes it to appear
as `+' in URLs, which Xapian ignores.
---
lib/PublicInbox/LeiXSearch.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 29df07e0c8a8..2958d3f910b0 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -342,7 +342,7 @@ sub query_remote_mboxrd {
local $SIG{TERM} = sub { exit(0) }; # for DESTROY (File::Temp, $reap)
my $lei = $self->{lei};
my $opt = $lei->{opt};
- my $qstr = $lei->{mset_opt}->{qstr};
+ chomp(my $qstr = $lei->{mset_opt}->{qstr});
$qstr =~ s/[ \n\t]+/ /sg; # make URLs less ugly
my @qform = (x => 'm');
push(@qform, t => 1) if $opt->{threads};
^ permalink raw reply related [relevance 6%]
* [PATCH 3/3] lei: normalize whitespace in remote queries
2021-09-11 0:19 6% ` [PATCH 0/3] lei saved-search fixes Eric Wong
@ 2021-09-11 0:19 7% ` Eric Wong
0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2021-09-11 0:19 UTC (permalink / raw)
To: meta; +Cc: Konstantin Ryabitsev
Having redundant "+" in URLs is ugly and can hurt cacheability
of queries. Even with "quoted phrase searches", Xapian seems
unaffected by redundant spaces, so just normalize the ASCII
white spaces to ' ' (%20) when fed via STDIN or saved-search
config file.
Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://public-inbox.org/meta/20210910141157.6u5adehpx7wftkor@meerkat.local/
---
lib/PublicInbox/LeiXSearch.pm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 709a3b3a..9f7f3885 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -297,7 +297,9 @@ sub query_remote_mboxrd {
local $SIG{TERM} = sub { exit(0) }; # for DESTROY (File::Temp, $reap)
my $lei = $self->{lei};
my $opt = $lei->{opt};
- my @qform = (q => $lei->{mset_opt}->{qstr}, x => 'm');
+ my $qstr = $lei->{mset_opt}->{qstr};
+ $qstr =~ s/[ \n\t]+/ /sg; # make URLs less ugly
+ my @qform = (q => $qstr, x => 'm');
push(@qform, t => 1) if $opt->{threads};
my $verbose = $opt->{verbose};
my ($reap_tail, $reap_curl);
^ permalink raw reply related [relevance 7%]
* [PATCH 0/3] lei saved-search fixes
@ 2021-09-11 0:19 6% ` Eric Wong
2021-09-11 0:19 7% ` [PATCH 3/3] lei: normalize whitespace in remote queries Eric Wong
0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2021-09-11 0:19 UTC (permalink / raw)
To: meta
Konstantin Ryabitsev wrote:
> I think it's reasonable to normalize \s+ into a single space for all queries,
> right?
Yes, 3/3 does it for HTTP(S). Don't think it's needed for local
queries. I'm leaving non-ASCII whitespace alone for now since I
don't think it'd be a real problem.
> Another observation is that when I missed a \ on one of the lines, I managed
> to make lei unusable. :)
That's a far more important problem fixed in 1/3 :>
Eric Wong (3):
lei: fix handling of broken lei.saved-search config files
lei: pass client stderr to git-config in more places
lei: normalize whitespace in remote queries
lib/PublicInbox/Config.pm | 10 ++--
lib/PublicInbox/LEI.pm | 23 +++++++--
lib/PublicInbox/LeiEditSearch.pm | 79 +++++++++++++++++++++++++++++--
lib/PublicInbox/LeiMirror.pm | 4 +-
lib/PublicInbox/LeiSavedSearch.pm | 77 ++++++------------------------
lib/PublicInbox/LeiXSearch.pm | 4 +-
script/lei | 2 +
t/lei-q-save.t | 17 +++++++
8 files changed, 136 insertions(+), 80 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-3 of 3 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-09-10 14:11 RFC: normalize whitespace in lei queries Konstantin Ryabitsev
2021-09-11 0:19 6% ` [PATCH 0/3] lei saved-search fixes Eric Wong
2021-09-11 0:19 7% ` [PATCH 3/3] lei: normalize whitespace in remote queries Eric Wong
2021-11-10 10:25 [PATCH 0/4] "lei q" rawstr fallout + fixes Eric Wong
2021-11-10 10:28 6% ` [PATCH 4/4] lei q: make HTTP(S) query strings even less ugly 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).