Skip to content

Commit 52dba41

Browse files
committed
Allow generic exception for replace= option
Related issue: uBlockOrigin/uBlock-issues#3791
1 parent 5d88b72 commit 52dba41

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/js/static-filtering-parser.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ export class AstFilterParser {
12451245
let modifierType = 0;
12461246
let requestTypeCount = 0;
12471247
let unredirectableTypeCount = 0;
1248-
let badfilter = false;
1248+
let isBadfilter = false;
12491249
for ( let i = 0, n = this.nodeTypeRegisterPtr; i < n; i++ ) {
12501250
const type = this.nodeTypeRegister[i];
12511251
const targetNode = this.nodeTypeLookupTable[type];
@@ -1269,7 +1269,7 @@ export class AstFilterParser {
12691269
realBad = hasValue;
12701270
break;
12711271
case NODE_TYPE_NET_OPTION_NAME_BADFILTER:
1272-
badfilter = true;
1272+
isBadfilter = true;
12731273
/* falls through */
12741274
case NODE_TYPE_NET_OPTION_NAME_NOOP:
12751275
realBad = isNegated || hasValue;
@@ -1423,9 +1423,6 @@ export class AstFilterParser {
14231423
this.addFlags(AST_FLAG_HAS_ERROR);
14241424
}
14251425
}
1426-
const requiresTrustedSource = ( ) =>
1427-
this.options.trustedSource !== true &&
1428-
isException === false && badfilter === false;
14291426
switch ( modifierType ) {
14301427
case NODE_TYPE_NET_OPTION_NAME_CNAME:
14311428
realBad = abstractTypeCount || behaviorTypeCount || requestTypeCount;
@@ -1453,7 +1450,8 @@ export class AstFilterParser {
14531450
case NODE_TYPE_NET_OPTION_NAME_REPLACE: {
14541451
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
14551452
if ( realBad ) { break; }
1456-
if ( requiresTrustedSource() ) {
1453+
if ( isException || isBadfilter ) { break; }
1454+
if ( this.options.trustedSource !== true ) {
14571455
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
14581456
realBad = true;
14591457
break;
@@ -1468,7 +1466,8 @@ export class AstFilterParser {
14681466
case NODE_TYPE_NET_OPTION_NAME_URLSKIP: {
14691467
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
14701468
if ( realBad ) { break; }
1471-
if ( requiresTrustedSource() ) {
1469+
if ( isException || isBadfilter ) { break; }
1470+
if ( this.options.trustedSource !== true ) {
14721471
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
14731472
realBad = true;
14741473
break;
@@ -1483,7 +1482,8 @@ export class AstFilterParser {
14831482
case NODE_TYPE_NET_OPTION_NAME_URLTRANSFORM: {
14841483
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
14851484
if ( realBad ) { break; }
1486-
if ( requiresTrustedSource() ) {
1485+
if ( isException || isBadfilter ) { break; }
1486+
if ( this.options.trustedSource !== true ) {
14871487
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
14881488
realBad = true;
14891489
break;

0 commit comments

Comments
 (0)