Skip to content

Commit

Permalink
Add -safebase64 directive in urlskip=
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Nov 20, 2024
1 parent 3aac2a7 commit bcc058e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/js/static-net-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -5417,6 +5417,8 @@ StaticNetFilteringEngine.prototype.transformRequest = function(fctxt, out = [])
*
* `-base64`: decode the current string as a base64-encoded string.
*
* `-safebase64`: decode the current string as a safe base64-encoded string.
*
* `-uricomponent`: decode the current string as a URI encoded string.
*
* `-blocked`: allow the redirection of blocked requests. By default, blocked
Expand Down Expand Up @@ -5498,6 +5500,12 @@ function urlSkip(directive, url, blocked, steps) {
urlout = self.atob(urlin);
continue;
}
// Safe Base64
if ( step === '-safebase64' ) {
urlout = urlin.replace(/[-_]/, safeBase64Replacer);
urlout = self.atob(urlout);
continue;
}
// URI component
if ( step === '-uricomponent' ) {
urlout = self.decodeURIComponent(urlin);
Expand Down Expand Up @@ -5543,6 +5551,9 @@ function urlSkip(directive, url, blocked, steps) {
}
}

const safeBase64Map = { '-': '+', '_': '/' };
const safeBase64Replacer = s => safeBase64Map[s];

/******************************************************************************/

// https://github.com/uBlockOrigin/uBlock-issues/issues/1626
Expand Down

0 comments on commit bcc058e

Please sign in to comment.