1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

Remove trusted-source requireement when using badfilter

Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3136
This commit is contained in:
Raymond Hill 2024-02-28 12:14:59 -05:00
parent ad03f7d86a
commit 3c299b8632
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1299,6 +1299,7 @@ export class AstFilterParser {
let modifierType = 0;
let requestTypeCount = 0;
let unredirectableTypeCount = 0;
let badfilter = false;
for ( let i = 0, n = this.nodeTypeRegisterPtr; i < n; i++ ) {
const type = this.nodeTypeRegister[i];
const targetNode = this.nodeTypeLookupTable[type];
@ -1322,6 +1323,8 @@ export class AstFilterParser {
realBad = hasValue;
break;
case NODE_TYPE_NET_OPTION_NAME_BADFILTER:
badfilter = true;
/* falls through */
case NODE_TYPE_NET_OPTION_NAME_NOOP:
realBad = isNegated || hasValue;
break;
@ -1462,6 +1465,9 @@ export class AstFilterParser {
this.addFlags(AST_FLAG_HAS_ERROR);
}
}
const requiresTrustedSource = ( ) =>
this.options.trustedSource !== true &&
isException === false && badfilter === false;
switch ( modifierType ) {
case NODE_TYPE_NET_OPTION_NAME_CNAME:
realBad = abstractTypeCount || behaviorTypeCount || requestTypeCount;
@ -1489,7 +1495,7 @@ export class AstFilterParser {
case NODE_TYPE_NET_OPTION_NAME_REPLACE: {
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
if ( realBad ) { break; }
if ( isException !== true && this.options.trustedSource !== true ) {
if ( requiresTrustedSource() ) {
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
realBad = true;
break;
@ -1504,7 +1510,7 @@ export class AstFilterParser {
case NODE_TYPE_NET_OPTION_NAME_URLTRANSFORM: {
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
if ( realBad ) { break; }
if ( isException !== true && this.options.trustedSource !== true ) {
if ( requiresTrustedSource() ) {
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
realBad = true;
break;