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:
Raymond Hill 2024-08-17 10:11:18 -04:00
parent 8de454ccca
commit 1cb660b94e
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 65 additions and 74 deletions

View File

@ -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';
/******************************************************************************/
@ -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;
}