From 66c70cf746c1863d9d3733502658617d77f4d146 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 7 Apr 2023 18:10:50 -0400 Subject: [PATCH] Fix improper detection of quotes in quoted strings Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2586 --- src/js/scriptlets/noscript-spoof.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/js/scriptlets/noscript-spoof.js b/src/js/scriptlets/noscript-spoof.js index 6c2898015..db9d57d0f 100644 --- a/src/js/scriptlets/noscript-spoof.js +++ b/src/js/scriptlets/noscript-spoof.js @@ -33,7 +33,7 @@ const noscripts = document.querySelectorAll('noscript'); if ( noscripts.length === 0 ) { return; } - const reMetaContent = /^\s*(\d+)\s*;\s*url=(['"]?)([^'"]+)\2/i; + const reMetaContent = /^\s*(\d+)\s*;\s*url=(?:"([^"]+)"|'([^']+)'|(.+))/i; const reSafeURL = /^https?:\/\//; let redirectTimer; @@ -41,15 +41,14 @@ const meta = root.querySelector('meta[http-equiv="refresh"][content]'); if ( meta === null ) { return; } const match = reMetaContent.exec(meta.getAttribute('content')); - if ( match === null || match[3].trim() === '' ) { return; } - + if ( match === null ) { return; } + const refreshURL = (match[2] || match[3] || match[4] || '').trim(); let url; try { - url = new URL(match[3], document.baseURI); + url = new URL(refreshURL, document.baseURI); } catch(ex) { return; } - if ( reSafeURL.test(url.href) === false ) { return; } redirectTimer = setTimeout(( ) => { location.assign(url.href);