Skip to content

Commit

Permalink
Improve href-sanitizer sciptlet
Browse files Browse the repository at this point in the history
Tolerate unexpected spaces in extracted URL parameters.

Related feedback:
uBlockOrigin/uBlock-issues#3297 (comment)
  • Loading branch information
gorhill committed Aug 12, 2024
1 parent 1822d15 commit db3dc69
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}
Expand Down

0 comments on commit db3dc69

Please sign in to comment.