From 2b9aba27489274a42bcc03ae7ac1da3bb33305a9 Mon Sep 17 00:00:00 2001 From: vt <85783377+vtriolet@users.noreply.github.com> Date: Sat, 31 Jul 2021 13:16:33 -0400 Subject: [PATCH] Handle invalid meta refresh URLs in noscript scriptlet Invalid URLs like "http://" and "http://foo@" trigger TypeErrors when they are passed to the URL constructor. These TypeErrors caused the scriptlet to stop processing subsequent noscript nodes due to uncaught exceptions. These exceptions are now caught to allow all noscript nodes to be processed. --- src/js/scriptlets/noscript-spoof.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/js/scriptlets/noscript-spoof.js b/src/js/scriptlets/noscript-spoof.js index 76f7896b8..2e6f0fdf7 100644 --- a/src/js/scriptlets/noscript-spoof.js +++ b/src/js/scriptlets/noscript-spoof.js @@ -42,7 +42,14 @@ if ( meta === null ) { return; } let match = reMetaContent.exec(meta.getAttribute('content')); if ( match === null || match[3].trim() === '' ) { return; } - let url = new URL(match[3], document.baseURI); + + let url; + try { + url = new URL(match[3], document.baseURI); + } catch(ex) { + return; + } + if ( reSafeURL.test(url.href) === false ) { return; } redirectTimer = setTimeout(( ) => { location.assign(url.href);