This bug is analogous to Bug 13442, but it affects shelf location rather than collection code: Limiting a search by shelf location is broken, because it wraps double-quotes around the "value" part of the key-value pair in the URL. This breaks the href= part of the anchor tag. The anchor tag generated for the shelf location faced is <a href="/cgi-bin/koha/opac-search.pl?&limit=mc-loc%3A"100100ADFICCF"&limit=mc-loc%3A"100200ADFIC"&limit=mc-loc%3A"100250ADFICGN"&limit=mc-loc%3A"100300ADFICHF"&limit=yr%2Cst-numeric%3D2014-&sort_by=acqdate_dsc&limit=au:Paetro%2C%20Maxine%2C" title="Paetro, Maxine,">Paetro, Maxine,</a> Once again, double-quotes inside the URL are causing a premature close of the href, which results in a broken link. I think that we need to take a look for code duplication inside C4::Search::buildQuery -- if there's more than one section of code where we're wrapping quotes around the 'value' part of the query, these should be consolidated -- shouldn't we be using URL encoding for URL reserved characters anyway?
(In reply to Barton Chittenden from comment #0) > This bug is analogous to Bug 13442, but it affects shelf location rather > than collection code: > > Limiting a search by shelf location is broken, because it wraps > double-quotes around the "value" part of the key-value pair in the URL. This > breaks the href= part of the anchor tag. > > The anchor tag generated for the shelf location faced is > > <a > href="/cgi-bin/koha/opac-search.pl?&limit=mc-loc%3A"100100ADFICCF"&limit=mc- > loc%3A"100200ADFIC"&limit=mc-loc%3A"100250ADFICGN"&limit=mc- > loc%3A"100300ADFICHF"&limit=yr%2Cst-numeric%3D2014-& > sort_by=acqdate_dsc&limit=au:Paetro%2C%20Maxine%2C" title="Paetro, > Maxine,">Paetro, Maxine,</a> > > Once again, double-quotes inside the URL are causing a premature close of > the href, which results in a broken link. > > I think that we need to take a look for code duplication inside > C4::Search::buildQuery -- if there's more than one section of code where > we're wrapping quotes around the 'value' part of the query, these should be > consolidated -- shouldn't we be using URL encoding for URL reserved > characters anyway? I found another example, this time in facets under Subject: Starting here: https://library.roseville.ca.us/cgi-bin/koha/opac-detail.pl?biblionumber=35767&query_desc=kw%2Cwrdl%3A%20Fairies Click on Subject: Faries ... this leads us here: https://library.roseville.ca.us/cgi-bin/koha/opac-search.pl?q=su:"Fairies." All of the facets on this page are broken, because the quotes are passed straight in, without being URL encoded. Here's an example from the HTML of that page: <span class="facet-label"><a href="/cgi-bin/koha/opac-search.pl?q=ccl=su%3A"Fairies."&sort_by=relevance_asc&limit=su-to:Magic" title="Magic">Magic</a></span>
Created attachment 37528 [details] [review] Bug 13812 - Facet links broken because double-quotes are not URL encoded. This bug is analogous to Bug 13442, but it affects shelf location rather than collection code: Limiting a search by shelf location is broken, because it wraps double-quotes around the "value" part of the key-value pair in the URL. This breaks the href= part of the anchor tag. The anchor tag generated for the shelf location faced is <a href="/cgi-bin/koha/opac-search.pl?&limit=mc-loc%3A"100100ADFICCF"&limit=mc-loc%3A"100200ADFIC"&limit=mc-loc%3A"100250ADFICGN"&limit=mc-loc%3A"100300ADFICHF"&limit=yr%2Cst-numeric%3D2014-&sort_by=acqdate_dsc&limit=au:Paetro%2C%20Maxine%2C" title="Paetro, Maxine,">Paetro, Maxine,</a> Once again, double-quotes inside the URL are causing a premature close of the href, which results in a broken link. http://bugs.koha-community.org/show_bug.cgi?id=13821
Patch removes quotes. Another possibility would be to escape or encode the quotes, but I'm not well versed enough with the XSLT to do so.
(In reply to Kyle M Hall from comment #3) > Patch removes quotes. Another possibility would be to escape or encode the > quotes, but I'm not well versed enough with the XSLT to do so. We could register an extension function with XML::LibXSLT, using XML::LibXSLT::register_function(), that allows us to escape or encode quotes. While I think XSLT 2.0 has a uri encoding function, XSLT 1.0 doesn't, so extension functions have to be used. I thought about adding this to the XSLT handler, but it's a global option, so we can just set it after "use XML::LibXSLT" to make the extension function available. (I wonder a bit about the repercussions while using Plack, but I don't yet know enough about Plack to really speculate on that one. I suppose it depends on the scope in which XML::LibXSLT is loaded.)
Is tis still valid on master? I can't recreate, could use a test plan.
I can't reproduce this on master either. It looks like the problem caused by: https://library.roseville.ca.us/cgi-bin/koha/opac-search.pl?q=su:%22Fairies.%22 is specific to either 3.16.4 or a modification that Bywater have made to that Koha instance. Here's a link that I see in the Roseville site for the query https://library.roseville.ca.us/cgi-bin/koha/opac-search.pl?q=su:%22Fairies.%22: <a href="/cgi-bin/koha/opac-search.pl?q=ccl=su%3A" fairies."&sort_by="relevance_asc&limit=au:Colfer%2C%20Eoin."" title="Colfer, Eoin.">Colfer, Eoin.</a> However, my query for http://192.168.1.61:2112/cgi-bin/koha/catalogue/search.pl?q=su:%22Fairies.%22 creates the following link: <a href="/cgi-bin/koha/catalogue/search.pl?q=ccl=su%3A%22Fairies.%22&sort_by=relevance_dsc&limit=itype:TEST" title="TEST">test</a> I suspect that the following line in C4::Search::buildQuery() was added after 3.16.4: $limit_cgi .= "&limit=" . uri_escape_utf8($this_limit); Although it looks like the Roseville site is also doing something with lowercasing and possibly whitespace as well... --- I suspect that the current patch might cause problems if it's used since it removes the TracingQuotesLeft and TracingQuotesRight, which are { and } with ICU, and only " and " with non-ICU. In any case, this doesn't appear to be a problem in master.
I think we see this happen with single quotes in an author name in facets. The name is: Kum'a N'dumbe. A keyword search for the name works, but when you search au:Kum'a N'dumbe - no results. Same when you click on the facet with this name: /cgi-bin/koha/catalogue/search.pl?idx=kw&q=kamerun&sort_by=relevance_dsc&limit=au:Kum'a N'dumbe, Alexandre
(In reply to Katrin Fischer from comment #7) > I think we see this happen with single quotes in an author name in facets. > The name is: Kum'a N'dumbe. A keyword search for the name works, but when > you search au:Kum'a N'dumbe - no results. Same when you click on the facet > with this name: > > > /cgi-bin/koha/catalogue/search. > pl?idx=kw&q=kamerun&sort_by=relevance_dsc&limit=au:Kum'a N'dumbe, Alexandre Thanks for that info. I'll try to reproduce this one, and see about writing a quick patch...
(In reply to Katrin Fischer from comment #7) > I think we see this happen with single quotes in an author name in facets. > The name is: Kum'a N'dumbe. A keyword search for the name works, but when > you search au:Kum'a N'dumbe - no results. Same when you click on the facet > with this name: > > > /cgi-bin/koha/catalogue/search. > pl?idx=kw&q=kamerun&sort_by=relevance_dsc&limit=au:Kum'a N'dumbe, Alexandre This is the URL that appears for my facets in master: /cgi-bin/koha/opac-search.pl?idx=kw&q=test&sort_by=relevance_dsc&limit=au:Kum%27a%20N%27dumbe,%20Alexandre The URL works although it does look like the ampersands are being erroneously escaped as well...
Just realized that Katrin's comment is from February 2017. I see there is a html filter on the OPAC template: <span class="facet-label"><a href="[% local_url | html %]" title="[% facet.facet_title_value | html %]">[% facet.facet_label_value | html %]</a></span> I have no idea why we're html escaping the URL... But it does seem to work...
Ah Jonathan is all over this at #21526
Seems to be fixed in master *** This bug has been marked as a duplicate of bug 21526 ***