]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: normalize whitespace in remote queries
authorEric Wong <e@80x24.org>
Sat, 11 Sep 2021 00:19:17 +0000 (00:19 +0000)
committerEric Wong <e@80x24.org>
Sat, 11 Sep 2021 00:24:16 +0000 (00:24 +0000)
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

index 709a3b3ab7ed4efe2177a922fe32e9576d51ba99..9f7f3885a3a6fce2a120bb23416d109495c324ad 100644 (file)
@@ -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);