From 1aaaaeb93fb374732e1cae91d4f53cdfe475f3b1 Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Fri, 4 Oct 2024 16:23:51 +0200 Subject: [PATCH] Fix CodeQL scanning issue test 3 Tryng to pass CodeQL security check on DOM text reinterpreted as HTML problem ISSUE: ADPM-70 --- src/views/js/front/adyen-wallets.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/views/js/front/adyen-wallets.js b/src/views/js/front/adyen-wallets.js index ce3c95fa..d22f2c67 100644 --- a/src/views/js/front/adyen-wallets.js +++ b/src/views/js/front/adyen-wallets.js @@ -19,15 +19,6 @@ $(document).ready(function () { event.preventDefault(); // Prevents the form from being submitted for ApplePay button } - function isValidURL(url) { - try { - const parsedUrl = new URL(url); - return true; - } catch (err) { - return false; - } - } - if (amazonCheckoutSessionId) { if (checkBox && !checkBox.is(':checked')) { // If not checked, set it to checked @@ -149,12 +140,12 @@ $(document).ready(function () { window.location.href = response.nextStepUrl; }, error: function () { - const checkoutUrlValue = checkoutUrl.value; - if (!isValidURL(checkoutUrlValue)) { - console.error('Invalid URL, redirection aborted.'); - return; + try { + const checkoutUrlObject = new URL(checkoutUrl.value); + window.location.href = checkoutUrlObject.href; + } catch (err) { + console.error('Invalid URL, redirection aborted.', err); } - window.location.href = checkoutUrlValue; } }); }