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.
This commit is contained in:
vt 2021-07-31 13:16:33 -04:00
parent bb20159495
commit 2b9aba2748
1 changed files with 8 additions and 1 deletions

View File

@ -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);