Bug 37998

Summary: Tabs and backslashes in the data break item search display
Product: Koha Reporter: Janusz Kaczmarek <januszop>
Component: SearchingAssignee: Janusz Kaczmarek <januszop>
Status: Pushed to oldstable --- QA Contact: Paul Derscheid <paul.derscheid>
Severity: minor    
Priority: P5 - low CC: fridolin.somers, johanna.raisa, jonathan.druart, lucas, paul.derscheid, pmis
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00,24.05.06
Circulation function:
Attachments: Bug 37998: Tabs and backslashes in the data break item search display
Bug 37998: Tabs and backslashes in the data break item search display
Bug 37998: Tabs and backslashes in the data break item search display
Bug 37998: (QA follow-up) Remove excess whitespace in catalogue/itemsearch_item.json.inc

Description Janusz Kaczmarek 2024-09-24 13:59:23 UTC
If the item data (e.g. callnumber) contains a tab or backslash OR the title part contains a backslash, the DataTable displaying the item search results stops throwing an error modal "Something went wrong when loading the table. 200: OK." and a JS console log: "DataTables warning: table id=results - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1".

The solution would be to apply $To filter in itemsearch_item.json.inc not only for biblioitem.publishercode but to all elements (also in biblio-title.inc).
Comment 1 Janusz Kaczmarek 2024-09-24 21:57:27 UTC
Created attachment 171954 [details] [review]
Bug 37998: Tabs and backslashes in the data break item search display

If the item data (e.g. callnumber) contains a tab or backslash OR the
title part contains a backslash, the DataTable displaying the item
search results stops throwing an error modal "Something went wrong when
loading the table. 200: OK." and a JS console log: "DataTables warning:
table id=results - Invalid JSON response. For more information about
this error, please see http://datatables.net/tn/1".

Test plan:
==========

1. Make an item search w/o any parameters.
2. From the first result page choose a record and modify the title (245 $a)
   to contain " \ " string. Repeat the item search. You should see a modal
   "Something went wrong when loading the table. 200: OK.".
3. Remove the " \ " from the title.  Verify that the problem no longer occurs.
4. In the same record, insert the string " \ " or a tab (copied from a text
   editor) into item data (itemcallnumber, enumchron, barcode etc.).
5. Repeat the item search. You should see again a modal "Something went wrong
   when loading the table. 200: OK.".
6. Apply the patch; restart_all.
7. Repeat p. 2, 3, 4, and 5.  Verify, that the problem is solved.

Sponsored-by: Ignatianum University in Cracow
Comment 2 Roman Dolny 2024-09-25 10:05:44 UTC
Created attachment 171955 [details] [review]
Bug 37998: Tabs and backslashes in the data break item search display

If the item data (e.g. callnumber) contains a tab or backslash OR the
title part contains a backslash, the DataTable displaying the item
search results stops throwing an error modal "Something went wrong when
loading the table. 200: OK." and a JS console log: "DataTables warning:
table id=results - Invalid JSON response. For more information about
this error, please see http://datatables.net/tn/1".

Test plan:
==========

1. Make an item search w/o any parameters.
2. From the first result page choose a record and modify the title (245 $a)
   to contain " \ " string. Repeat the item search. You should see a modal
   "Something went wrong when loading the table. 200: OK.".
3. Remove the " \ " from the title.  Verify that the problem no longer occurs.
4. In the same record, insert the string " \ " or a tab (copied from a text
   editor) into item data (itemcallnumber, enumchron, barcode etc.).
5. Repeat the item search. You should see again a modal "Something went wrong
   when loading the table. 200: OK.".
6. Apply the patch; restart_all.
7. Repeat p. 2, 3, 4, and 5.  Verify, that the problem is solved.

Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 3 Paul Derscheid 2024-11-07 11:48:45 UTC
Created attachment 174127 [details] [review]
Bug 37998: Tabs and backslashes in the data break item search display

If the item data (e.g. callnumber) contains a tab or backslash OR the
title part contains a backslash, the DataTable displaying the item
search results stops throwing an error modal "Something went wrong when
loading the table. 200: OK." and a JS console log: "DataTables warning:
table id=results - Invalid JSON response. For more information about
this error, please see http://datatables.net/tn/1".

Test plan:
==========

1. Make an item search w/o any parameters.
2. From the first result page choose a record and modify the title (245 $a)
   to contain " \ " string. Repeat the item search. You should see a modal
   "Something went wrong when loading the table. 200: OK.".
3. Remove the " \ " from the title.  Verify that the problem no longer occurs.
4. In the same record, insert the string " \ " or a tab (copied from a text
   editor) into item data (itemcallnumber, enumchron, barcode etc.).
5. Repeat the item search. You should see again a modal "Something went wrong
   when loading the table. 200: OK.".
6. Apply the patch; restart_all.
7. Repeat p. 2, 3, 4, and 5.  Verify, that the problem is solved.

Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 4 Paul Derscheid 2024-11-07 11:52:51 UTC
Created attachment 174149 [details] [review]
Bug 37998: (QA follow-up) Remove excess whitespace in catalogue/itemsearch_item.json.inc
Comment 5 Katrin Fischer 2024-11-08 10:24:55 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 6 Lucas Gass (lukeg) 2024-12-05 22:07:50 UTC
BAckported to 24.05.x for upcoming 24.05.06
Comment 7 Johanna Räisä 2024-12-10 07:25:29 UTC
*** Bug 38631 has been marked as a duplicate of this bug. ***
Comment 8 Fridolin Somers 2024-12-18 12:43:59 UTC
Great catch.

I'm a bit concerned changing biblio-title.inc.

This include is called in many places that are not JSON format.
I see filter To removes starting+ending double quotes for example.

Should we add a parameter to it :
[% INCLUDE 'biblio-title.inc' json=1 %]
Comment 9 Jonathan Druart 2025-01-13 09:44:31 UTC
koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title.inc is the exact same file and has not been modified.