mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-29 06:07:11 +02: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
|
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 * as sfp from './static-filtering-parser.js';
|
||||||
|
|
||||||
import {
|
import { domainFromHostname, hostnameFromNetworkURL } from './uri-utils.js';
|
||||||
domainFromHostname,
|
import { dropTask, queueTask } from './tasks.js';
|
||||||
hostnameFromNetworkURL,
|
|
||||||
} from './uri-utils.js';
|
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility
|
import BidiTrieContainer from './biditrie.js';
|
||||||
//
|
import { CompiledListReader } from './static-filtering-io.js';
|
||||||
// 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 { FilteringContext } from './filtering-context.js';
|
import { FilteringContext } from './filtering-context.js';
|
||||||
|
import HNTrieContainer from './hntrie.js';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@ -3423,63 +3410,63 @@ class FilterCompiler {
|
|||||||
|
|
||||||
processOptionWithValue(parser, id) {
|
processOptionWithValue(parser, id) {
|
||||||
switch ( id ) {
|
switch ( id ) {
|
||||||
case sfp.NODE_TYPE_NET_OPTION_NAME_CSP:
|
case sfp.NODE_TYPE_NET_OPTION_NAME_CSP:
|
||||||
if ( this.processCspOption(parser.getNetOptionValue(id)) === false ) { return false; }
|
if ( this.processCspOption(parser.getNetOptionValue(id)) === false ) { return false; }
|
||||||
break;
|
break;
|
||||||
case sfp.NODE_TYPE_NET_OPTION_NAME_DENYALLOW:
|
case sfp.NODE_TYPE_NET_OPTION_NAME_DENYALLOW:
|
||||||
this.denyallowOpt = this.processHostnameList(
|
this.denyallowOpt = this.processHostnameList(
|
||||||
parser.getNetFilterDenyallowOptionIterator(),
|
parser.getNetFilterDenyallowOptionIterator(),
|
||||||
);
|
);
|
||||||
if ( this.denyallowOpt === '' ) { return false; }
|
if ( this.denyallowOpt === '' ) { return false; }
|
||||||
this.optionUnitBits |= DENYALLOW_BIT;
|
this.optionUnitBits |= DENYALLOW_BIT;
|
||||||
break;
|
break;
|
||||||
case sfp.NODE_TYPE_NET_OPTION_NAME_FROM:
|
case sfp.NODE_TYPE_NET_OPTION_NAME_FROM:
|
||||||
this.fromDomainOpt = this.processHostnameList(
|
this.fromDomainOpt = this.processHostnameList(
|
||||||
parser.getNetFilterFromOptionIterator(),
|
parser.getNetFilterFromOptionIterator(),
|
||||||
this.fromDomainOptList
|
this.fromDomainOptList
|
||||||
);
|
);
|
||||||
if ( this.fromDomainOpt === '' ) { return false; }
|
if ( this.fromDomainOpt === '' ) { return false; }
|
||||||
this.optionUnitBits |= FROM_BIT;
|
this.optionUnitBits |= FROM_BIT;
|
||||||
break;
|
break;
|
||||||
case sfp.NODE_TYPE_NET_OPTION_NAME_HEADER: {
|
case sfp.NODE_TYPE_NET_OPTION_NAME_HEADER: {
|
||||||
this.headerOpt = parser.getNetOptionValue(id) || '';
|
this.headerOpt = parser.getNetOptionValue(id) || '';
|
||||||
this.optionUnitBits |= HEADER_BIT;
|
this.optionUnitBits |= HEADER_BIT;
|
||||||
break;
|
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.optionUnitBits |= MODIFY_BIT;
|
||||||
this.processMethodOption(parser.getNetOptionValue(id));
|
break;
|
||||||
this.optionUnitBits |= METHOD_BIT;
|
case sfp.NODE_TYPE_NET_OPTION_NAME_REDIRECT: {
|
||||||
break;
|
const actualId = this.action === ALLOW_REALM
|
||||||
case sfp.NODE_TYPE_NET_OPTION_NAME_PERMISSIONS:
|
? sfp.NODE_TYPE_NET_OPTION_NAME_REDIRECTRULE
|
||||||
case sfp.NODE_TYPE_NET_OPTION_NAME_REDIRECTRULE:
|
: id;
|
||||||
case sfp.NODE_TYPE_NET_OPTION_NAME_REMOVEPARAM:
|
if ( this.processModifierOption(actualId, parser.getNetOptionValue(id)) === false ) {
|
||||||
case sfp.NODE_TYPE_NET_OPTION_NAME_REPLACE:
|
return false;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
case sfp.NODE_TYPE_NET_OPTION_NAME_TO:
|
this.optionUnitBits |= MODIFY_BIT;
|
||||||
this.toDomainOpt = this.processHostnameList(
|
break;
|
||||||
parser.getNetFilterToOptionIterator(),
|
}
|
||||||
this.toDomainOptList
|
case sfp.NODE_TYPE_NET_OPTION_NAME_TO:
|
||||||
);
|
this.toDomainOpt = this.processHostnameList(
|
||||||
if ( this.toDomainOpt === '' ) { return false; }
|
parser.getNetFilterToOptionIterator(),
|
||||||
this.optionUnitBits |= TO_BIT;
|
this.toDomainOptList
|
||||||
break;
|
);
|
||||||
default:
|
if ( this.toDomainOpt === '' ) { return false; }
|
||||||
break;
|
this.optionUnitBits |= TO_BIT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -3798,7 +3785,7 @@ class FilterCompiler {
|
|||||||
isJustOrigin() {
|
isJustOrigin() {
|
||||||
if ( this.optionUnitBits !== FROM_BIT ) { return false; }
|
if ( this.optionUnitBits !== FROM_BIT ) { return false; }
|
||||||
if ( this.isRegex ) { 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.pattern === '*' ) { return true; }
|
||||||
if ( this.anchor !== 0b010 ) { return false; }
|
if ( this.anchor !== 0b010 ) { return false; }
|
||||||
if ( /^(?:http[s*]?:(?:\/\/)?)$/.test(this.pattern) ) { return true; }
|
if ( /^(?:http[s*]?:(?:\/\/)?)$/.test(this.pattern) ) { return true; }
|
||||||
@ -5156,6 +5143,10 @@ StaticNetFilteringEngine.prototype.matchHeaders = function(fctxt, headers) {
|
|||||||
if ( r !== 0 && $isBlockImportant !== true ) {
|
if ( r !== 0 && $isBlockImportant !== true ) {
|
||||||
if ( this.realmMatchString(HEADERS_REALM | ALLOW_REALM, typeBits, partyBits) ) {
|
if ( this.realmMatchString(HEADERS_REALM | ALLOW_REALM, typeBits, partyBits) ) {
|
||||||
r = 2;
|
r = 2;
|
||||||
|
} else if ( this.realmMatchString(ALLOW_REALM, typeBits, partyBits) ) {
|
||||||
|
r = 2;
|
||||||
|
}
|
||||||
|
if ( r === 2 ) {
|
||||||
if ( this.realmMatchString(HEADERS_REALM | BLOCKIMPORTANT_REALM, typeBits, partyBits) ) {
|
if ( this.realmMatchString(HEADERS_REALM | BLOCKIMPORTANT_REALM, typeBits, partyBits) ) {
|
||||||
r = 1;
|
r = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user