Skip to content

Commit

Permalink
Add -uricomponent to urlskip= option
Browse files Browse the repository at this point in the history
To unescape URI-encoded characters.

Related discussion:
uBlockOrigin/uBlock-issues#3206 (comment)
  • Loading branch information
gorhill committed Oct 11, 2024
1 parent 4d982d9 commit 01eebff
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/js/static-net-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -5406,6 +5406,8 @@ StaticNetFilteringEngine.prototype.transformRequest = function(fctxt, out = [])
*
* `-base64`: decode the current string as a base64-encoded string.
*
* `-uricomponent`: decode the current string as a URI component string.
*
* At any given step, the currently extracted string may not necessarily be
* a valid URL, and more transformation steps may be needed to obtain a valid
* URL once all the steps are applied.
Expand Down Expand Up @@ -5470,10 +5472,18 @@ function urlSkip(directive, urlin, steps) {
urlout = `https://${s}`;
continue;
}
// Decode base64
if ( c0 === 0x2D && step === '-base64' ) {
urlout = self.atob(urlin);
continue;
// Decode
if ( c0 === 0x2D ) {
// Base64
if ( step === '-base64' ) {
urlout = self.atob(urlin);
continue;
}
// URI component
if ( step === '-uricomponent' ) {
urlout = self.decodeURIComponent(urlin);
continue;
}
}
// Regex extraction from first capture group
if ( c0 === 0x2F ) { // /
Expand Down

0 comments on commit 01eebff

Please sign in to comment.