| Summary: | Quotation marks in series fields (490/830) break XSLT search links in Elasticsearch | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Slava Shishkin <slavashishkin> |
| Component: | Staff interface | Assignee: | Slava Shishkin <slavashishkin> |
| Status: | Failed QA --- | QA Contact: | Testopia <testopia> |
| Severity: | enhancement | ||
| Priority: | P5 - low | CC: | bernard.scaife, caroline.cyr-la-rose, gmcharlt |
| Version: | Main | ||
| Hardware: | All | ||
| OS: | All | ||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Comma delimited list of Sponsors: | |
| Crowdfunding goal: | 0 | 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
Bug 40569: Escape quotation marks in series fields in XSLT search links (Elasticsearch) Hi, |
||
Created attachment 184944 [details] [review] Bug 40569: Escape quotation marks in series fields in XSLT search links 1. Create or edit a bibliographic record (beter more then 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 malformed query 6. Apply the patch 7. Reload the bibliographic detail page 8. Click the Series link again 9. The search should return matching records 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 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\"" 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 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 Created attachment 186245 [details] [review] Hi, It works fine for me as well. I’m not changing the status since I also find Bernard’s suggestion interesting. Signed-off-by: noah <noah@inlibro.com> 1) QA checks - all pass! 2) Code review I don't believe this is the right fix. It adds quoting, but it removed the URL encoding that I believe is also needed: - <a><xsl:attribute name="href"><xsl:value-of select="$searchurl"/>?q=se,phr:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>"</xsl:attribute> + <a><xsl:attribute name="href"><xsl:value-of select="$searchurl"/>?q=se,phr:<xsl:call-template name="quote_search_term"> + <xsl:with-param name="term"><xsl:value-of select="marc:subfield[@code='a']"/></xsl:with-param> + </xsl:call-template> + </xsl:attribute> quote_search_term only adds " and escapes quotes in the string. Hope I am not missing something. 3) Other I notice that the sign-off line for Noah could be a little nicer :) Signed-off-by: noah <noah@inlibro.com> Added assignee. |
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