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 modifierType = 0;
|
||||||
let requestTypeCount = 0;
|
let requestTypeCount = 0;
|
||||||
let unredirectableTypeCount = 0;
|
let unredirectableTypeCount = 0;
|
||||||
let badfilter = false;
|
let isBadfilter = false;
|
||||||
for ( let i = 0, n = this.nodeTypeRegisterPtr; i < n; i++ ) {
|
for ( let i = 0, n = this.nodeTypeRegisterPtr; i < n; i++ ) {
|
||||||
const type = this.nodeTypeRegister[i];
|
const type = this.nodeTypeRegister[i];
|
||||||
const targetNode = this.nodeTypeLookupTable[type];
|
const targetNode = this.nodeTypeLookupTable[type];
|
||||||
|
|
@ -1269,7 +1269,7 @@ export class AstFilterParser {
|
||||||
realBad = hasValue;
|
realBad = hasValue;
|
||||||
break;
|
break;
|
||||||
case NODE_TYPE_NET_OPTION_NAME_BADFILTER:
|
case NODE_TYPE_NET_OPTION_NAME_BADFILTER:
|
||||||
badfilter = true;
|
isBadfilter = true;
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case NODE_TYPE_NET_OPTION_NAME_NOOP:
|
case NODE_TYPE_NET_OPTION_NAME_NOOP:
|
||||||
realBad = isNegated || hasValue;
|
realBad = isNegated || hasValue;
|
||||||
|
|
@ -1423,9 +1423,6 @@ export class AstFilterParser {
|
||||||
this.addFlags(AST_FLAG_HAS_ERROR);
|
this.addFlags(AST_FLAG_HAS_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const requiresTrustedSource = ( ) =>
|
|
||||||
this.options.trustedSource !== true &&
|
|
||||||
isException === false && badfilter === false;
|
|
||||||
switch ( modifierType ) {
|
switch ( modifierType ) {
|
||||||
case NODE_TYPE_NET_OPTION_NAME_CNAME:
|
case NODE_TYPE_NET_OPTION_NAME_CNAME:
|
||||||
realBad = abstractTypeCount || behaviorTypeCount || requestTypeCount;
|
realBad = abstractTypeCount || behaviorTypeCount || requestTypeCount;
|
||||||
|
|
@ -1453,7 +1450,8 @@ export class AstFilterParser {
|
||||||
case NODE_TYPE_NET_OPTION_NAME_REPLACE: {
|
case NODE_TYPE_NET_OPTION_NAME_REPLACE: {
|
||||||
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
|
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
|
||||||
if ( realBad ) { break; }
|
if ( realBad ) { break; }
|
||||||
if ( requiresTrustedSource() ) {
|
if ( isException || isBadfilter ) { break; }
|
||||||
|
if ( this.options.trustedSource !== true ) {
|
||||||
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
||||||
realBad = true;
|
realBad = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1468,7 +1466,8 @@ export class AstFilterParser {
|
||||||
case NODE_TYPE_NET_OPTION_NAME_URLSKIP: {
|
case NODE_TYPE_NET_OPTION_NAME_URLSKIP: {
|
||||||
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
|
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
|
||||||
if ( realBad ) { break; }
|
if ( realBad ) { break; }
|
||||||
if ( requiresTrustedSource() ) {
|
if ( isException || isBadfilter ) { break; }
|
||||||
|
if ( this.options.trustedSource !== true ) {
|
||||||
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
||||||
realBad = true;
|
realBad = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1483,7 +1482,8 @@ export class AstFilterParser {
|
||||||
case NODE_TYPE_NET_OPTION_NAME_URLTRANSFORM: {
|
case NODE_TYPE_NET_OPTION_NAME_URLTRANSFORM: {
|
||||||
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
|
realBad = abstractTypeCount || behaviorTypeCount || unredirectableTypeCount;
|
||||||
if ( realBad ) { break; }
|
if ( realBad ) { break; }
|
||||||
if ( requiresTrustedSource() ) {
|
if ( isException || isBadfilter ) { break; }
|
||||||
|
if ( this.options.trustedSource !== true ) {
|
||||||
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
||||||
realBad = true;
|
realBad = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue