From 8298e708b9dda5b4bec561eebc94414fd964a141 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Wed, 4 Sep 2024 20:38:27 -0700 Subject: [PATCH] Bug 37801: Search results with limits create URLs that cause XML errors in RSS and Atom output The template for RSS and Atom feeds of search results (curiously named opac-opensearch.tt) is careful to escape ampersands in the query_cgi param while adding it to URLs, but doesn't escape the limit_cgi param at all. It should. Two drive-by fixes for Atom: because the when your search has a limit includes  , which isn't an XML character entity, you couldn't get as far as the error from the <link> URL, and as long as I was going to have blame for the line, I couldn't bear to leave the stray undefined SEARCH_RESULT. in the (hard-coded and bogus) <link rel="last">. Test plan: 1. In the OPAC, Advanced search - check the boxes to limit by item type Books and Mixed Materials and search for the keyword Perl 2. At the top of the search results, click the orange RSS icon 3. That gives you an ugly "not well-formed" error, so in the URL for the page change the final "format=rss" to "format=atom" 4. That gives you an ugly "undefined entity" error, so apply the patch 5. Reload the page with the Atom feed, it should change from an error page to a garbled display of the feed. Click Back to go back to the RSS feed and reload it if it's still cached on the error page. That should give a pretty-printed display of the RSS feed without parsing errors Sponsored-by: Chetco Community Public Library Signed-off-by: Sukhmandeep Benipal <sukhmandeep.benipal@inLibro.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> --- .../bootstrap/en/modules/opac-opensearch.tt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-opensearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-opensearch.tt index 14e7889834..0983f004b3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-opensearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-opensearch.tt @@ -39,9 +39,9 @@ <![CDATA[[% LibraryName | html %] Search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %] with limit(s): '[% limit_desc | html %]'[% END %]]]> - [% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | replace('&', '&') | $raw %][% limit_cgi | $raw %]&sort_by=[% sort_by | uri %]&format=rss + [% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | replace('&', '&') | $raw %][% limit_cgi | replace('&', '&') | $raw %]&sort_by=[% sort_by | uri %]&format=rss - + @@ -52,7 +52,7 @@ [% ELSE %] 20 [% END %] -