From db3dc69bcc500ca273e70bb8fa000ad29ccfc586 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 12 Aug 2024 13:45:46 -0400 Subject: [PATCH] Improve `href-sanitizer` sciptlet Tolerate unexpected spaces in extracted URL parameters. Related feedback: https://github.com/uBlockOrigin/uBlock-issues/issues/3297#issuecomment-2283806183 --- assets/resources/scriptlets.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index 866b30667..8cbeb386a 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -3551,9 +3551,12 @@ function hrefSanitizer( const end = recursive ? source.indexOf('?', 1) : source.length; try { const url = new URL(href, document.location); - const value = url.searchParams.get(source.slice(1, end)); + let value = url.searchParams.get(source.slice(1, end)); if ( value === null ) { return href } if ( recursive ) { return extractParam(value, source.slice(end)); } + if ( value.includes(' ') ) { + value = value.replace(/ /g, '%20'); + } return value; } catch(x) { }