From 836cf31cb89c9c65487bdbd36ed8bf5ea7f25f98 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 11 Mar 2025 16:53:28 +0000 Subject: [PATCH] Bug 39307: Check to make sure there is a document.referrer To test: 1. Navigate to circ/circulation.pl?borrowernumber=X 2. See the console error `document.referrer.split(...)[1] is undefined` 3. APPLY PATCH 4. JS error should be gone Signed-off-by: Phil Ringnalda Signed-off-by: Brendan Lawlor --- .../prog/en/modules/circ/circulation.tt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index d81f3522f6..3afcb050b0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -1210,13 +1210,14 @@ // Handle checkout for fast cataloging // Check the referrer to prevent csrf, fill and submit form - if(document.referrer.split(window.location.origin + '/cgi-bin/koha/cataloguing/additem.pl?')[1].match(/frameworkcode=FA&circborrowernumber=/) ) { - let urlParams = new URLSearchParams(window.location.search); - let barcode = urlParams.get('barcode'); - $('#barcode').val(barcode); - $('#mainform').submit(); + if ( document.referrer.length ) { + if(document.referrer.split(window.location.origin + '/cgi-bin/koha/cataloguing/additem.pl?')[1].match(/frameworkcode=FA&circborrowernumber=/) ) { + let urlParams = new URLSearchParams(window.location.search); + let barcode = urlParams.get('barcode'); + $('#barcode').val(barcode); + $('#mainform').submit(); + } } - $("#cancellation-reason").comboBox({ displayProperty: 'name', placeholder: _("Select or type a reason"), -- 2.39.5