AdguardTeam / ecsstree

Adblock Extended CSS supplement for CSSTree
MIT License
10 stars 1 forks source link

Improve `:contains` extended pseudo-class #11

Open scripthunter7 opened 1 year ago

scripthunter7 commented 1 year ago

If the ( ) balancing is not correct, it is impossible to clearly determine the actual end of the pseudo-class. For example:

In the above cases, parenthesis must be escaped as follows:

But the following cases are fine, since balancing is fine:

The following cases are currently problematic in ECSSTree (throws parsing error):

This is because ECSSTree overrides CSSTree's default algorithm while parsing :contains() and currently ONLY parses the argument as raw (and not takes string into account like CSSTree). If we introduce the string node management here, the following case must also be taken into account:

See https://github.com/AdguardTeam/FiltersCompiler/issues/156#issuecomment-1442892854

@slavaleleka What do you think about this?

scripthunter7 commented 1 year ago

@slavaleleka It seems ExtendedCSS also throws an error for

But not for

scripthunter7 commented 1 year ago

This should also be fixed:

:contains(/(\(| |^)EqG[) ]/)

(square brackets should also be included in the balancing when searching)

scripthunter7 commented 2 months ago

will fix once we integrate @adguard/css-tokenizer