mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 01:02:08 +01:00
Fix broken http header filtering
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2552
This commit is contained in:
parent
285ce54d9c
commit
72cc9a8fe8
1 changed files with 16 additions and 16 deletions
|
@ -41,12 +41,10 @@ const $exceptions = new Set();
|
||||||
let acceptedCount = 0;
|
let acceptedCount = 0;
|
||||||
let discardedCount = 0;
|
let discardedCount = 0;
|
||||||
|
|
||||||
const headerIndexFromName = function(name, headers) {
|
const headerIndexFromName = function(name, headers, start = 0) {
|
||||||
let i = headers.length;
|
for ( let i = start; i < headers.length; i++ ) {
|
||||||
while ( i-- ) {
|
if ( headers[i].name.toLowerCase() !== name ) { continue; }
|
||||||
if ( headers[i].name.toLowerCase() === name ) {
|
return i;
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
@ -138,7 +136,7 @@ httpheaderFilteringEngine.fromCompiledContent = function(reader) {
|
||||||
duplicates.add(fingerprint);
|
duplicates.add(fingerprint);
|
||||||
const args = reader.args();
|
const args = reader.args();
|
||||||
if ( args.length < 4 ) { continue; }
|
if ( args.length < 4 ) { continue; }
|
||||||
filterDB.store(args[1], args[2], args[3].slice(15, -1));
|
filterDB.store(args[1], args[2], args[3]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -175,18 +173,20 @@ httpheaderFilteringEngine.apply = function(fctxt, headers) {
|
||||||
const hasGlobalException = $exceptions.has('');
|
const hasGlobalException = $exceptions.has('');
|
||||||
|
|
||||||
let modified = false;
|
let modified = false;
|
||||||
|
let i = 0;
|
||||||
|
|
||||||
for ( const name of $headers ) {
|
for ( const name of $headers ) {
|
||||||
for (;;) {
|
const isExcepted = hasGlobalException || $exceptions.has(name);
|
||||||
const i = headerIndexFromName(name, headers);
|
if ( isExcepted ) {
|
||||||
if ( i === -1 ) { break; }
|
if ( logger.enabled ) {
|
||||||
const isExcepted = hasGlobalException || $exceptions.has(name);
|
logOne(true, hasGlobalException ? '' : name, fctxt);
|
||||||
if ( isExcepted ) {
|
|
||||||
if ( logger.enabled ) {
|
|
||||||
logOne(true, hasGlobalException ? '' : name, fctxt);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
for (;;) {
|
||||||
|
i = headerIndexFromName(name, headers, i);
|
||||||
|
if ( i === -1 ) { break; }
|
||||||
headers.splice(i, 1);
|
headers.splice(i, 1);
|
||||||
if ( logger.enabled ) {
|
if ( logger.enabled ) {
|
||||||
logOne(false, name, fctxt);
|
logOne(false, name, fctxt);
|
||||||
|
|
Loading…
Reference in a new issue