Bug 40569 - Quotation marks in series fields (490/830) break XSLT search links in Elasticsearch
Summary: Quotation marks in series fields (490/830) break XSLT search links in Elastic...
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-31 17:41 UTC by Slava Shishkin
Modified: 2025-08-13 14:25 UTC (History)
2 users (show)

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


Attachments
Bug 40569: Escape quotation marks in series fields in XSLT search links (3.65 KB, patch)
2025-07-31 17:52 UTC, Slava Shishkin
Details | Diff | Splinter Review
Bug 40569: Escape quotation marks in series fields in XSLT search links (Elasticsearch) (3.77 KB, patch)
2025-08-11 13:10 UTC, Slava Shishkin
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Slava Shishkin 2025-07-31 17:41:44 UTC
Search links generated from series fields in the XSLT detail view (MARC 440a/490a/830a) fail when the series title contains quotation marks ("), due to the lack of escaping in the generated URL.

Steps to reproduce:
1. Create or edit a bibliographic record (better more than one)
2. In field 490$a or 830$a, enter a series name with quotes, e.g., Test "Series"
3. Save the record
4. On the detail page, click the Series link (generated from the XSLT view) Series: Test "Series"
5. The search fails or returns an error due to a malformed query
Comment 1 Slava Shishkin 2025-07-31 17:52:51 UTC Comment hidden (obsolete)
Comment 2 Bernard 2025-08-08 14:13:24 UTC
Strangely this works fine for me without any fix using test plan. 25.06.00.002 using Chrome 138.0.7204.184. Maybe different browsers are less forgiving? Rendered url that results is cgi-bin/koha/catalogue/search.pl?q=se,phr:%22Test%20%22Series%22%22
Comment 3 Slava Shishkin 2025-08-11 12:33:40 UTC
Thanks, Bernard, for checking!

My apologies, I forgot to mention that this only happens when SearchEngine = Elasticsearch — with Zebra, it works fine.

The issue is not browser-specific. Without escaping, the generated ES query contains raw quotes:

se,phr:"Test "Series""

In this case, Koha returns in the browser:

No results found  
No results match your search for '"se,phr:"Test "Series"""'.

With the patch, quotes are escaped, and the query becomes:

se,phr:"Test \"Series\""
Comment 4 Slava Shishkin 2025-08-11 13:10:25 UTC
Created attachment 185309 [details] [review]
Bug 40569: Escape quotation marks in series fields in XSLT search links (Elasticsearch)

1. Choose Elasticsearch like Search engine: cgi-bin/koha/admin/preferences.pl?op=search&searchfield=SearchEngine
2. Create or edit a bibliographic record (beter more then one)
3. In field 490$a or 830$a, enter a series name with quotes, e.g. Test "Series"
4. Save the record
5. On the detail page, click the Series link (generated from the XSLT view)Series: Test "Series"
6. The search fails or returns an error due to malformed query
7. Apply the patch
8. Reload the bibliographic detail page
9. Click the Series link again
10. The search should return matching records
Comment 5 Bernard 2025-08-13 14:25:43 UTC
Hi Slava,

I replicated it this time with elastic :)

Your patch works fine! Does it also need to be on line 490 of MARC21slimUtils.xsl which also has se,phr ?

Also it would be great to add to the OPAC xslt too where I think we have the same issue.

/kohadevbox/koha/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl
lines are 381, 406, 454 and 505.

thanks

Bernard