From 997e636d7b199d11bfa86082b08e8956b79e8302 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Wed, 17 Feb 2021 12:49:32 -0300 Subject: [PATCH] Bug 27719: Apply _escape_str and _escape_price where needed This bug replaces calls for .escapeHtml and format_price for there null checking counterparts To test: 1: have a fresh Koha Testing Docker 2: have a basket set to create item records on ordering 3: populate basket from a marc file, only setting price and fund for the items 4: close basket 5: click to Receive, create invoice 6: on parcel.pl, "Processing" alert never resolves CHECK => The console shows: parcel.pl?invoiceid=1:810 Uncaught TypeError: Cannot read property 'format_price' of null at render (parcel.pl?invoiceid=1:810) at datatables.min_20.1200012.js:57 at Object.b.fnGetData (datatables.min_20.1200012.js:51) at B (datatables.min_20.1200012.js:56) at Ha (datatables.min_20.1200012.js:64) at P (datatables.min_20.1200012.js:68) at vb (datatables.min_20.1200012.js:79) at datatables.min_20.1200012.js:76 at i (datatables.min_20.1200012.js:74) at Object.success (datatables.min_20.1200012.js:75) And that error points toward: "data": "replacement_price", "render": function(data, type, row, meta) { return (row.replacement_price).format_price(); }, }, 7: apply patch 8: redo steps 5 and 6 SUCCESS => "Processing" alert doesn't hangs, and prices with null values are empty. Sponsored-by: Virginia Polytechnic Institute and State University --- .../prog/en/modules/acqui/parcel.tt | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index 855b044d50..c9253973f0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -402,7 +402,7 @@ "orderable": true, "render": function(data, type, row, meta) { if (type != 'display') return _escape_str(data); - return "" + data.escapeHtml() + " (" + row.basket.basket_id.escapeHtml() + ")"; + return "" + _escape_str(data) + " (" + _escape_str(row.basket.basket_id) + ")"; } }, { "data": "basket.basket_group.name", @@ -418,7 +418,7 @@ return "" - + row.basket.basket_group.name.escapeHtml() + " (" + row.basket.basket_group_id.escapeHtml() + ")"; + + _escape_str(row.basket.basket_group.name) + " (" + _escape_str(row.basket.basket_group_id) + ")"; } } }, @@ -426,7 +426,7 @@ "data": "order_id", "render": function(data, type, row, meta) { if (type != 'display') return _escape_str(data); - return ""+data.escapeHtml()+""; + return ""+_escape_str(data)+""; } }, { @@ -436,22 +436,22 @@ "render": function(data, type, row, meta) { var result = ''; if ( row && row.biblio_id != null ) { - result = "

"+row.biblio.title.escapeHtml()+""; + result = "

"+_escape_str(row.biblio.title)+""; if ( row.biblio.author != null ) - result += _(" by ") + row.biblio.author.escapeHtml(); + result += _(" by ") + _escape_str(row.biblio.author); if ( row.biblio.isbn != null ) - result += " – " + row.biblio.isbn.escapeHtml(); + result += " – " + _escape_str(row.biblio.isbn); [% IF Koha.Preference('marcflavour')=='UNIMARC' %] if ( row.biblio.ean != null ) - result += " – EAN:" + row.biblio.ean.escapeHtml(); + result += " – EAN:" + _escape_str(row.biblio.ean); [% END %] if ( row.biblio.publisher != null ) { - result += "
" + _("Publisher: ") + row.biblio.publisher.escapeHtml(); + result += "
" + _("Publisher: ") + _escape_str(row.biblio.publisher); if ( row.biblio.publication_year != null ) { - result += ", " + row.biblio.publication_year.escapeHtml(); + result += ", " + _escape_str(row.biblio.publication_year); } else if ( row.biblio.copyright_date != null ) { - result += row.biblio.copyright_date.escapeHtml(); + result += _escape_str(row.biblio.copyright_date); } } var suggestions = row.biblio.suggestions; @@ -461,10 +461,10 @@ var suggester = suggestion.suggester; var suggested_by = []; if ( suggester.surname != null ) { - suggested_by.push(suggester.surname.escapeHtml()); + suggested_by.push(_escape_str(suggester.surname)); } if ( suggester.firstname != null ) { - suggested_by.push(suggester.firstname.escapeHtml()); + suggested_by.push(_escape_str(suggester.firstname)); } result += "
" + _("Suggested by: ") + @@ -472,7 +472,7 @@ + encodeURIComponent(suggestion.suggestionid) + '&op=show">' + suggested_by.join(", ") - + " (#" + suggestions[0].suggestionid.escapeHtml() + ")"; // FIXME: could be changed if we allow matching multiple suggestions + + " (#" + _escape_str(suggestions[0].suggestionid) + ")"; // FIXME: could be changed if we allow matching multiple suggestions } } result += '

'; @@ -482,7 +482,7 @@ if ( internal_note != null && internal_note != '' ) { result += '

' + _("Internal note: ") - + '' + internal_note.escapeHtml() + + '' + _escape_str(internal_note) + ' [' + _("Change internal note") + ']

'; @@ -497,7 +497,7 @@ if ( vendor_note != null && vendor_note != '' ) { result += '

' + _("Vendor note: ") - + '' + vendor_note.escapeHtml() + '

'; + + '' + _escape_str(vendor_note) + '

'; } else { result += ' [' + _("Receive") + '
' - + '' + + '' + _("Transfer") + ''; }, "orderable": false, @@ -570,7 +570,7 @@ if ( row.current_holds_count > 0 ) { result += '' + + _("Can't cancel order, (%s) holds are linked with this order. Cancel holds first").format( _escape_str(row.holds_count) ) + '">' + _("Can't cancel order") + '
'; } else { -- 2.25.0