Bug 37801 - Search results with limits create URLs that cause XML errors in RSS2 output
Summary: Search results with limits create URLs that cause XML errors in RSS2 output
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Phil Ringnalda
QA Contact: Jonathan Druart
URL:
Keywords:
: 38238 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-09-02 06:59 UTC by David Cook
Modified: 2024-11-15 15:45 UTC (History)
5 users (show)

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


Attachments
Bug 37801: Search results with limits create URLs that cause XML errors in RSS and Atom output (8.80 KB, patch)
2024-09-05 03:52 UTC, Phil Ringnalda
Details | Diff | Splinter Review
Screenshot of the result after patch is applied (183.19 KB, image/png)
2024-09-10 20:30 UTC, Sukhmandeep
Details
Bug 37801: Search results with limits create URLs that cause XML errors in RSS and Atom output (8.87 KB, patch)
2024-09-10 20:42 UTC, Sukhmandeep
Details | Diff | Splinter Review
Bug 37801: Search results with limits create URLs that cause XML errors in RSS and Atom output (8.95 KB, patch)
2024-09-11 13:01 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2024-09-02 06:59:22 UTC
To reproduce:

1. Go to http://localhost:8080/cgi-bin/koha/opac-search.pl
2. Limit to "Books" and click "Search"
3. Click the RSS icon
4. Note the XML parsing error:

This page contains the following errors:
error on line 1 at column 364: EntityRef: expecting ';'
Below is a rendering of the page up to the first error.
Comment 1 Phil Ringnalda 2024-09-05 03:52:50 UTC Comment hidden (obsolete)
Comment 2 Sukhmandeep 2024-09-10 20:30:41 UTC
Created attachment 171290 [details]
Screenshot of the result after patch is applied

Hi Phil,

I’ve completed the test plan, and everything seems to be functioning as expected. However, I’m unsure about the part that states, "That should give a pretty-printed display of the RSS feed without parsing errors." I’ve attached a screenshot of the result I obtained. Could you please confirm if this matches the expected outcome?

Thanks!
Comment 3 Phil Ringnalda 2024-09-10 20:34:33 UTC
Yes, that's perfect. Sorry for being unclear, pretty-printed is the Firefox rendering engine's internal name for that particular display of XML, and this is the first time I've ever mentioned it to anyone who wasn't involved in creating it, so it didn't occur to me that nobody else knows that's what it's called :)
Comment 4 Sukhmandeep 2024-09-10 20:40:36 UTC
Ah, got it. Everything seems to be functioning as expected, so I'll sign off this bug.
Comment 5 Sukhmandeep 2024-09-10 20:42:18 UTC Comment hidden (obsolete)
Comment 6 Jonathan Druart 2024-09-11 13:01:22 UTC
Created attachment 171305 [details] [review]
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 <title> when your search has a limit
includes &nbsp;, 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>
Comment 7 Katrin Fischer 2024-09-13 11:58:31 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 8 Owen Leonard 2024-09-13 12:24:55 UTC
> The template for RSS and Atom feeds of search results (curiously named
> opac-opensearch.tt)

The name was related to this: https://en.wikipedia.org/wiki/OpenSearch
Comment 9 Baptiste Wojtkowski (bwoj) 2024-10-23 12:46:48 UTC
*** Bug 38238 has been marked as a duplicate of this bug. ***
Comment 10 Lucas Gass (lukeg) 2024-10-25 21:02:30 UTC
Backported to 24.05.x for upcoming 24.05.05
Comment 11 Fridolin Somers 2024-11-15 15:45:45 UTC
Pushed to 23.11.x for 23.11.11