Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support :not(:matches-path()) conversion #1725

Closed
sfionov opened this issue Feb 10, 2023 · 9 comments
Closed

Support :not(:matches-path()) conversion #1725

sfionov opened this issue Feb 10, 2023 · 9 comments

Comments

@sfionov
Copy link
Member

sfionov commented Feb 10, 2023

Now it is not possible to easily create negated rules (you should create an regexp)

It will be nice to add some syntax for path negation

We may also add support for uBO syntax :not(:matches-path()).

@ameshkov
Copy link
Member

ameshkov commented May 16, 2023

It would make sense to use the standard approach with ~ for inverting the modifier behavior, i.e.: [~path="/test"]##banner.

On the other hand, do we really need it? If negative lookahead is supported in the $path modifier, we don't need it at all.
In any case, we need to change the converter to make it work.

@adguard-bot adguard-bot changed the title Add $path negation for cosmetic rules Support :not(:matches-path()) conversion May 16, 2023
@sfionov
Copy link
Member Author

sfionov commented May 16, 2023

It will be simpler to convert :not(:matches-path()) rules if we support path negation. Especially if it already contains a regexp.

@ameshkov
Copy link
Member

I'd just like to not add more modifiers if it can be avoided. Even a regular expression is easily converted: regex -> (!?regex)

@stanislav-atr
Copy link

This was already done as part of this issue.

@ameshkov
Copy link
Member

@stanislav-atr how exactly was the conversion done? Negative lookhead?

@stanislav-atr
Copy link

yes, for example, rule ya.ru##:not(:matches-path(/\/(sub1|sub2)\/page\.html/))p is being converted into [$path=/^((?!\\/(sub1|sub2)\\/page\\.html).)*$/]ya.ru##p

@ameshkov
Copy link
Member

Good, I think this is exactly what we should do in CoreLibs.

Could you please link the relevant part of tsurlfilter's code?

@sxgunchenko
Copy link

It is already done along with #1530

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants