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>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit d289ebf0b3)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Janusz Kaczmarek 2024-09-24 21:05:32 +00:00 committed by Lucas Gass
parent b3dd152c5e
commit 76f82167f1
2 changed files with 12 additions and 11 deletions

View File

@ -1,3 +1,4 @@
[%- USE To -%]
[%- IF link && ! biblio %][% link = 0 %][% END %]
[%- IF ( link ) -%]
<a href="[%- PROCESS biblio_a_href biblionumber => biblio.biblionumber -%]" class="title">
@ -8,23 +9,23 @@
[%- ELSIF !biblio.title -%]
<span class="biblio-no-title">No title</span>
[%- ELSE -%]
<span class="biblio-title">[% biblio.title | html %]</span>
<span class="biblio-title">[% biblio.title | html | $To %]</span>
[%- END -%]
[%- IF ( biblio.medium ) -%]
<span class="biblio-medium">[%- biblio.medium | html -%]</span>
<span class="biblio-medium">[%- biblio.medium | html | $To -%]</span>
[%- END -%]
[%- FOREACH subtitle IN biblio.subtitle.split(' \\| ') -%][%- IF Koha.Preference('marcflavour')=='UNIMARC' -%],[%- END -%]
<span class="subtitle">[%- subtitle | html -%]</span>
<span class="subtitle">[%- subtitle | html | $To -%]</span>
[%- END -%]
[%- part_numbers = biblio.part_number.split(' \\| ') -%]
[%- part_names = biblio.part_name.split(' \\| ') -%]
[%- i = 0 -%]
[%- WHILE ( part_numbers.$i.defined || part_names.$i.defined ) -%]
[%- IF ( part_numbers.$i.defined ) -%]
<span class="part-number">[%- part_numbers.$i | html -%]</span>
<span class="part-number">[%- part_numbers.$i | html | $To -%]</span>
[%- END -%]
[%- IF ( part_names.$i.defined ) -%]
<span class="part-name">[%- part_names.$i | html -%]</span>
<span class="part-name">[%- part_names.$i | html | $To -%]</span>
[%- END -%]
[%- i = i + 1 -%]
[%- END -%]

View File

@ -13,20 +13,20 @@
"[% FILTER escape_quotes ~%]
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]" title="Go to record detail page">[% INCLUDE 'biblio-title.inc' | trim | collapse %]</a>[% IF ( Koha.Preference( 'marcflavour' ) == 'UNIMARC' && biblio.author ) %] by[% END %] [% biblio.author | html %]
[%~ END %]",
"[% (biblioitem.publicationyear || biblio.copyrightdate) | html %]",
"[% (biblioitem.publicationyear || biblio.copyrightdate) | html | $To %]",
"[% biblioitem.publishercode | html | $To %]",
"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => item.ccode ) | html %]",
"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => item.ccode ) | html | $To %]",
"[% FILTER escape_quotes ~%]
<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblio.biblionumber | uri %]#item[% item.itemnumber | uri %]" title="Go to item details">[% item.barcode | html %]</a>
<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblio.biblionumber | uri %]#item[% item.itemnumber | uri %]" title="Go to item details">[% item.barcode | html | $To %]</a>
[%~ END %]",
"[% item.itemnumber | html %]",
"[% item.enumchron | html %]",
"[% item.itemcallnumber | html %]",
"[% item.enumchron | html | $To %]",
"[% item.itemcallnumber | html | $To %]",
"[% Branches.GetName(item.homebranch) | html %]",
"[% Branches.GetName(item.holdingbranch) | html %]",
"[% AuthorisedValues.GetDescriptionByKohaField( frameworkcode => biblio.frameworkcode, kohafield => 'items.location', authorised_value => item.location) | html %]",
"[% ItemTypes.GetDescription(item.itype) | html %]",
"[% item.stocknumber | html %]",
"[% item.stocknumber | html | $To %]",
"[% AuthorisedValues.GetDescriptionByKohaField( frameworkcode => biblio.frameworkcode, kohafield => 'items.notforloan', authorised_value => item.notforloan) | html %]",
"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost ) || "" | html %]",
"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn ) || "" | html %]",