mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Allow generic exception for replace= option
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/3791
This commit is contained in:
parent
5d88b72b47
commit
52dba4116e
1 changed files with 8 additions and 8 deletions
|
|
@ -1245,7 +1245,7 @@ export class AstFilterParser {
|
|||
let modifierType = 0;
|
||||
let requestTypeCount = 0;
|
||||
let unredirectableTypeCount = 0;
|
||||
let badfilter = false;
|
||||
let isBadfilter = false;
|
||||
for ( let i = 0, n = this.nodeTypeRegisterPtr; i < n; i++ ) {
|
||||
const type = this.nodeTypeRegister[i];
|
||||
const targetNode = this.nodeTypeLookupTable[type];
|
||||
|
|
@ -1269,7 +1269,7 @@ export class AstFilterParser {
|
|||
realBad = hasValue;
|
||||
break;
|
||||
case NODE_TYPE_NET_OPTION_NAME_BADFILTER:
|
||||
badfilter = true;
|
||||
isBadfilter = true;
|
||||
/* falls through */
|
||||
case NODE_TYPE_NET_OPTION_NAME_NOOP:
|
||||
realBad = isNegated || hasValue;
|
||||
|
|
@ -1423,9 +1423,6 @@ 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;
|
||||
|
|
@ -1453,7 +1450,8 @@ export class AstFilterParser {
|
|||
case NODE_TYPE_NET_OPTION_NAME_REPLACE: {
|
||||
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
|
||||
if ( realBad ) { break; }
|
||||
if ( requiresTrustedSource() ) {
|
||||
if ( isException || isBadfilter ) { break; }
|
||||
if ( this.options.trustedSource !== true ) {
|
||||
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
||||
realBad = true;
|
||||
break;
|
||||
|
|
@ -1468,7 +1466,8 @@ export class AstFilterParser {
|
|||
case NODE_TYPE_NET_OPTION_NAME_URLSKIP: {
|
||||
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
|
||||
if ( realBad ) { break; }
|
||||
if ( requiresTrustedSource() ) {
|
||||
if ( isException || isBadfilter ) { break; }
|
||||
if ( this.options.trustedSource !== true ) {
|
||||
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
||||
realBad = true;
|
||||
break;
|
||||
|
|
@ -1483,7 +1482,8 @@ export class AstFilterParser {
|
|||
case NODE_TYPE_NET_OPTION_NAME_URLTRANSFORM: {
|
||||
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
|
||||
if ( realBad ) { break; }
|
||||
if ( requiresTrustedSource() ) {
|
||||
if ( isException || isBadfilter ) { break; }
|
||||
if ( this.options.trustedSource !== true ) {
|
||||
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
||||
realBad = true;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue