1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-06 02:42:33 +01:00

[mv3] Fix regression in extended filtering with some lists

Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/236

Regression from:
https://github.com/gorhill/uBlock/commit/58bfe4c846

Cosmetic- and scriptlet injection-based filters broke with filter
lists using AdGuard's `[$domain=/.../]` syntax.

Potentially affected filter lists:
- AdGuard Chinese
- AdGuard Turkish
This commit is contained in:
Raymond Hill 2024-10-19 10:26:31 -04:00
parent 12435d96cc
commit d4f15ca635
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -19,12 +19,6 @@
Home: https://github.com/gorhill/uBlock
*/
'use strict';
/******************************************************************************/
import staticNetFilteringEngine from './static-net-filtering.js';
import { LineIterator } from './text-utils.js';
import * as sfp from './static-filtering-parser.js';
import {
@ -32,6 +26,9 @@ import {
CompiledListWriter,
} from './static-filtering-io.js';
import { LineIterator } from './text-utils.js';
import staticNetFilteringEngine from './static-net-filtering.js';
/******************************************************************************/
// http://www.cse.yorku.ca/~oz/hash.html#djb2
@ -47,13 +44,15 @@ const hashFromStr = (type, s) => {
return hash & 0xFFFFFF;
};
const isRegex = hn => hn.startsWith('/') && hn.endsWith('/');
/******************************************************************************/
// Copied from cosmetic-filter.js for the time being to avoid unwanted
// dependencies
const rePlainSelector = /^[#.][\w\\-]+/;
const rePlainSelectorEx = /^[^#.\[(]+([#.][\w-]+)|([#.][\w-]+)$/;
const rePlainSelectorEx = /^[^#.[(]+([#.][\w-]+)|([#.][\w-]+)$/;
const rePlainSelectorEscaped = /^[#.](?:\\[0-9A-Fa-f]+ |\\.|\w|-)+/;
const reEscapeSequence = /\\([0-9A-Fa-f]+ |.)/g;
@ -106,6 +105,7 @@ function addExtendedToDNR(context, parser) {
for ( const { hn, not, bad } of parser.getExtFilterDomainIterator() ) {
if ( bad ) { continue; }
if ( exception ) { continue; }
if ( isRegex(hn) ) { continue; }
let details = context.scriptletFilters.get(argsToken);
if ( details === undefined ) {
context.scriptletFilters.set(argsToken, details = { args });
@ -163,6 +163,7 @@ function addExtendedToDNR(context, parser) {
};
for ( const { hn, not, bad } of parser.getExtFilterDomainIterator() ) {
if ( bad ) { continue; }
if ( isRegex(hn) ) { continue; }
if ( not ) {
if ( rule.condition.excludedInitiatorDomains === undefined ) {
rule.condition.excludedInitiatorDomains = [];
@ -235,6 +236,7 @@ function addExtendedToDNR(context, parser) {
}
for ( const { hn, not, bad } of parser.getExtFilterDomainIterator() ) {
if ( bad ) { continue; }
if ( isRegex(hn) ) { continue; }
let { compiled, exception, raw } = parser.result;
if ( exception ) { continue; }
let rejected;