Add `-safebase64` directive in `urlskip=`

Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3206#issuecomment-2487392846
This commit is contained in:
Raymond Hill 2024-11-20 07:53:52 -05:00
parent 3aac2a7c97
commit bcc058eba7
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 11 additions and 0 deletions

View File

@ -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
@ -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);
@ -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