From 141e6cf68d553161d162e2d5c17e3945319ec6e7 Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Tue, 24 Sep 2024 21:05:32 +0000 Subject: [PATCH] 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 Signed-off-by: Paul Derscheid --- .../intranet-tmpl/prog/en/includes/biblio-title.inc | 11 ++++++----- .../en/includes/catalogue/itemsearch_item.json.inc | 12 ++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-title.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-title.inc index 66ebc8527a..694f569f57 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-title.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-title.inc @@ -1,3 +1,4 @@ +[%- USE To -%] [%- IF link && ! biblio %][% link = 0 %][% END %] [%- IF ( link ) -%] @@ -8,23 +9,23 @@ [%- ELSIF !biblio.title -%] No title [%- ELSE -%] - [% biblio.title | html %] + [% biblio.title | html | $To %] [%- END -%] [%- IF ( biblio.medium ) -%] - [%- biblio.medium | html -%] + [%- biblio.medium | html | $To -%] [%- END -%] [%- FOREACH subtitle IN biblio.subtitle.split(' \\| ') -%][%- IF Koha.Preference('marcflavour')=='UNIMARC' -%],[%- END -%] - [%- subtitle | html -%] + [%- subtitle | html | $To -%] [%- 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 ) -%] - [%- part_numbers.$i | html -%] + [%- part_numbers.$i | html | $To -%] [%- END -%] [%- IF ( part_names.$i.defined ) -%] - [%- part_names.$i | html -%] + [%- part_names.$i | html | $To -%] [%- END -%] [%- i = i + 1 -%] [%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc index d1eda11819..e78a231ce1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc @@ -13,20 +13,20 @@ "[% FILTER escape_quotes ~%] [% INCLUDE 'biblio-title.inc' | trim | collapse %][% 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 ~%] - [% item.barcode | html %] + [% item.barcode | html | $To %] [%~ 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 %]", -- 2.39.5