1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-06 02:42:33 +01:00

Add -uricomponent to urlskip= option

To unescape URI-encoded characters.

Related discussion:
https://github.com/uBlockOrigin/uBlock-issues/issues/3206#issuecomment-2406479971
This commit is contained in:
Raymond Hill 2024-10-11 08:54:50 -04:00
parent 4d982d9972
commit 01eebffc1f
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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.
@ -5470,11 +5472,19 @@ function urlSkip(directive, urlin, steps) {
urlout = `https://${s}`;
continue;
}
// Decode base64
if ( c0 === 0x2D && step === '-base64' ) {
// 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 ) { // /
if ( directive.cache === null ) {