mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-04 01:59:38 +02:00
Only already normalized CSS selectors can be fast path-compiled
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2730 CSS selectors used in cosmetic filtering are normalized in order to ignore non-functional differences. For instance: example.org##body p example.org#@#body p The first cosmetic filter should be excepted by the second one, but this was not the case because the fast path use to compile common CSS selectors was not causing normalization to take place. The fix is to ensure that the fast path used to compile most common CSS selectors is taken only when in presence of already normalized CSS selectors.
This commit is contained in:
parent
b107040d89
commit
0da7e12ea4
@ -793,7 +793,6 @@ export class AstFilterParser {
|
||||
this.reHostnameLabel = /[^.]+/g;
|
||||
this.reResponseheaderPattern = /^\^responseheader\(.*\)$/;
|
||||
this.rePatternScriptletJsonArgs = /^\{.*\}$/;
|
||||
// TODO: mind maxTokenLength
|
||||
this.reGoodRegexToken = /[^\x01%0-9A-Za-z][%0-9A-Za-z]{7,}|[^\x01%0-9A-Za-z][%0-9A-Za-z]{1,6}[^\x01%0-9A-Za-z]/;
|
||||
this.reBadCSP = /(?:=|;)\s*report-(?:to|uri)\b/;
|
||||
this.reOddTrailingEscape = /(?:^|[^\\])(?:\\\\)*\\$/;
|
||||
@ -3028,7 +3027,7 @@ class ExtSelectorCompiler {
|
||||
`${cssClassOrId}(?:${cssClassOrId})*(?:${cssAttribute})*` + '|' +
|
||||
`${cssAttribute}(?:${cssAttribute})*` +
|
||||
')';
|
||||
const cssCombinator = '(?:\\s+|\\s*[+>~]\\s*)';
|
||||
const cssCombinator = '(?: | [+>~] )';
|
||||
this.reCommonSelector = new RegExp(
|
||||
`^${cssSimple}(?:${cssCombinator}${cssSimple})*$`
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user