mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Remove trusted-source requireement when using badfilter
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/3136
This commit is contained in:
parent
ad03f7d86a
commit
3c299b8632
@ -1299,6 +1299,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;
|
||||||
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];
|
||||||
@ -1322,6 +1323,8 @@ 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;
|
||||||
|
/* falls through */
|
||||||
case NODE_TYPE_NET_OPTION_NAME_NOOP:
|
case NODE_TYPE_NET_OPTION_NAME_NOOP:
|
||||||
realBad = isNegated || hasValue;
|
realBad = isNegated || hasValue;
|
||||||
break;
|
break;
|
||||||
@ -1462,6 +1465,9 @@ 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;
|
||||||
@ -1489,7 +1495,7 @@ 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 ( isException !== true && this.options.trustedSource !== true ) {
|
if ( requiresTrustedSource() ) {
|
||||||
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
||||||
realBad = true;
|
realBad = true;
|
||||||
break;
|
break;
|
||||||
@ -1504,7 +1510,7 @@ 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 ( isException !== true && this.options.trustedSource !== true ) {
|
if ( requiresTrustedSource() ) {
|
||||||
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
this.astError = AST_ERROR_UNTRUSTED_SOURCE;
|
||||||
realBad = true;
|
realBad = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user