Bug 24781 - Parse and build query strings more reliably
Summary: Parse and build query strings more reliably
Status: RESOLVED WISHLIST
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-03 07:07 UTC by David Cook
Modified: 2022-12-06 06:21 UTC (History)
0 users

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2020-03-03 07:07:05 UTC
Throughout the code, you'll see a lot of string mangling to manipulate query strings.

Examples from opac-search.pl:

$query_cgi = "tag=" .  uri_escape_utf8( $tag ) . "&" . $query_cgi;

$pasarParams .= '&query=' . uri_escape_utf8($query);
$pasarParams .= '&count=' . uri_escape_utf8($results_per_page);
$pasarParams .= '&simple_query=' . uri_escape_utf8($simple_query);

$limit_cgi_not_availablity =~ s/&limit=available//g if defined $limit_cgi_not_availablity;

It would be good to have a more reliable unit-tested way of creating and editing query strings.

I have a module called Koha::Util::URL which should be able to help. I'm hoping to put together a patch tomorrow.
Comment 1 David Cook 2020-03-03 07:07:57 UTC
As a side note, I actually thought of this while creating a new "Peer-Reviewed" facet for the search results, which imitates that "Availability" facet to a degree. 

I didn't like the way limit=available was being handled, so I wrote an alternative.