]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
search_query: drop CR (`\r') from queries
authorEric Wong <e@80x24.org>
Mon, 9 Dec 2024 20:57:49 +0000 (20:57 +0000)
committerEric Wong <e@80x24.org>
Tue, 10 Dec 2024 18:11:13 +0000 (18:11 +0000)
w3m (and presumably other browsers) send CRLF instead of LF for
queries made from <textarea> from the VCS view.  CRs require
unnecessary escaping and make RLs look ugly, so omit them
to cleanup URLs and reduce memory traffic in Xapian.

lib/PublicInbox/SearchQuery.pm

index 747e32493ba2146b520ea01de1ab7584710fe0f2..e0127deae851a1cab7e6029941c37b0f5c9e0c79 100644 (file)
@@ -17,8 +17,10 @@ sub new {
        my ($l) = (($qp->{l} || '') =~ /([0-9]+)/);
        $l = $LIM if !$l || $l > $LIM;
        my ($o) = (($qp->{o} || '0') =~ /(-?[0-9]+)/);
+       my $q = $qp->{'q'};
+       $q =~ s/\r\n/\n/sg if defined $q;
        bless {
-               q => $qp->{'q'},
+               q => $q,
                x => $qp->{x} || '',
                o => $o,
                l => $l,