mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-05 18:32:30 +01:00
Fix plain exceptions not overriding block filters using header=
option
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/3347
This commit is contained in:
parent
8de454ccca
commit
1cb660b94e
@ -19,28 +19,15 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* globals vAPI */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import { queueTask, dropTask } from './tasks.js';
|
||||
import BidiTrieContainer from './biditrie.js';
|
||||
import HNTrieContainer from './hntrie.js';
|
||||
import { CompiledListReader } from './static-filtering-io.js';
|
||||
import * as sfp from './static-filtering-parser.js';
|
||||
|
||||
import {
|
||||
domainFromHostname,
|
||||
hostnameFromNetworkURL,
|
||||
} from './uri-utils.js';
|
||||
import { domainFromHostname, hostnameFromNetworkURL } from './uri-utils.js';
|
||||
import { dropTask, queueTask } from './tasks.js';
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility
|
||||
//
|
||||
// This import would be best done dynamically, but since dynamic imports are
|
||||
// not supported by older browsers, for now a static import is necessary.
|
||||
import BidiTrieContainer from './biditrie.js';
|
||||
import { CompiledListReader } from './static-filtering-io.js';
|
||||
import { FilteringContext } from './filtering-context.js';
|
||||
import HNTrieContainer from './hntrie.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -3423,63 +3410,63 @@ class FilterCompiler {
|
||||
|
||||
processOptionWithValue(parser, id) {
|
||||
switch ( id ) {
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_CSP:
|
||||
if ( this.processCspOption(parser.getNetOptionValue(id)) === false ) { return false; }
|
||||
break;
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_DENYALLOW:
|
||||
this.denyallowOpt = this.processHostnameList(
|
||||
parser.getNetFilterDenyallowOptionIterator(),
|
||||
);
|
||||
if ( this.denyallowOpt === '' ) { return false; }
|
||||
this.optionUnitBits |= DENYALLOW_BIT;
|
||||
break;
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_FROM:
|
||||
this.fromDomainOpt = this.processHostnameList(
|
||||
parser.getNetFilterFromOptionIterator(),
|
||||
this.fromDomainOptList
|
||||
);
|
||||
if ( this.fromDomainOpt === '' ) { return false; }
|
||||
this.optionUnitBits |= FROM_BIT;
|
||||
break;
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_HEADER: {
|
||||
this.headerOpt = parser.getNetOptionValue(id) || '';
|
||||
this.optionUnitBits |= HEADER_BIT;
|
||||
break;
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_CSP:
|
||||
if ( this.processCspOption(parser.getNetOptionValue(id)) === false ) { return false; }
|
||||
break;
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_DENYALLOW:
|
||||
this.denyallowOpt = this.processHostnameList(
|
||||
parser.getNetFilterDenyallowOptionIterator(),
|
||||
);
|
||||
if ( this.denyallowOpt === '' ) { return false; }
|
||||
this.optionUnitBits |= DENYALLOW_BIT;
|
||||
break;
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_FROM:
|
||||
this.fromDomainOpt = this.processHostnameList(
|
||||
parser.getNetFilterFromOptionIterator(),
|
||||
this.fromDomainOptList
|
||||
);
|
||||
if ( this.fromDomainOpt === '' ) { return false; }
|
||||
this.optionUnitBits |= FROM_BIT;
|
||||
break;
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_HEADER: {
|
||||
this.headerOpt = parser.getNetOptionValue(id) || '';
|
||||
this.optionUnitBits |= HEADER_BIT;
|
||||
break;
|
||||
}
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_METHOD:
|
||||
this.processMethodOption(parser.getNetOptionValue(id));
|
||||
this.optionUnitBits |= METHOD_BIT;
|
||||
break;
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_PERMISSIONS:
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_REDIRECTRULE:
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_REMOVEPARAM:
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_REPLACE:
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_URLTRANSFORM:
|
||||
if ( this.processModifierOption(id, parser.getNetOptionValue(id)) === false ) {
|
||||
return false;
|
||||
}
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_METHOD:
|
||||
this.processMethodOption(parser.getNetOptionValue(id));
|
||||
this.optionUnitBits |= METHOD_BIT;
|
||||
break;
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_PERMISSIONS:
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_REDIRECTRULE:
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_REMOVEPARAM:
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_REPLACE:
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_URLTRANSFORM:
|
||||
if ( this.processModifierOption(id, parser.getNetOptionValue(id)) === false ) {
|
||||
return false;
|
||||
}
|
||||
this.optionUnitBits |= MODIFY_BIT;
|
||||
break;
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_REDIRECT: {
|
||||
const actualId = this.action === ALLOW_REALM
|
||||
? sfp.NODE_TYPE_NET_OPTION_NAME_REDIRECTRULE
|
||||
: id;
|
||||
if ( this.processModifierOption(actualId, parser.getNetOptionValue(id)) === false ) {
|
||||
return false;
|
||||
}
|
||||
this.optionUnitBits |= MODIFY_BIT;
|
||||
break;
|
||||
this.optionUnitBits |= MODIFY_BIT;
|
||||
break;
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_REDIRECT: {
|
||||
const actualId = this.action === ALLOW_REALM
|
||||
? sfp.NODE_TYPE_NET_OPTION_NAME_REDIRECTRULE
|
||||
: id;
|
||||
if ( this.processModifierOption(actualId, parser.getNetOptionValue(id)) === false ) {
|
||||
return false;
|
||||
}
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_TO:
|
||||
this.toDomainOpt = this.processHostnameList(
|
||||
parser.getNetFilterToOptionIterator(),
|
||||
this.toDomainOptList
|
||||
);
|
||||
if ( this.toDomainOpt === '' ) { return false; }
|
||||
this.optionUnitBits |= TO_BIT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
this.optionUnitBits |= MODIFY_BIT;
|
||||
break;
|
||||
}
|
||||
case sfp.NODE_TYPE_NET_OPTION_NAME_TO:
|
||||
this.toDomainOpt = this.processHostnameList(
|
||||
parser.getNetFilterToOptionIterator(),
|
||||
this.toDomainOptList
|
||||
);
|
||||
if ( this.toDomainOpt === '' ) { return false; }
|
||||
this.optionUnitBits |= TO_BIT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -3798,7 +3785,7 @@ class FilterCompiler {
|
||||
isJustOrigin() {
|
||||
if ( this.optionUnitBits !== FROM_BIT ) { return false; }
|
||||
if ( this.isRegex ) { return false; }
|
||||
if ( /[\/~]/.test(this.fromDomainOpt) ) { return false; }
|
||||
if ( /[/~]/.test(this.fromDomainOpt) ) { return false; }
|
||||
if ( this.pattern === '*' ) { return true; }
|
||||
if ( this.anchor !== 0b010 ) { return false; }
|
||||
if ( /^(?:http[s*]?:(?:\/\/)?)$/.test(this.pattern) ) { return true; }
|
||||
@ -5156,6 +5143,10 @@ StaticNetFilteringEngine.prototype.matchHeaders = function(fctxt, headers) {
|
||||
if ( r !== 0 && $isBlockImportant !== true ) {
|
||||
if ( this.realmMatchString(HEADERS_REALM | ALLOW_REALM, typeBits, partyBits) ) {
|
||||
r = 2;
|
||||
} else if ( this.realmMatchString(ALLOW_REALM, typeBits, partyBits) ) {
|
||||
r = 2;
|
||||
}
|
||||
if ( r === 2 ) {
|
||||
if ( this.realmMatchString(HEADERS_REALM | BLOCKIMPORTANT_REALM, typeBits, partyBits) ) {
|
||||
r = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user