-
Notifications
You must be signed in to change notification settings - Fork 79
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
uBO doesn't reject cosmetic filters with invalid pseudo-classes/pseudo-elements #2442
Comments
It does if writing
Before CSSTree, uBO would use the browser's DOM API to validate selectors, and after years of patching cases to make it better at detecting (often breaking something else as a result) while ending up with a difficult to maintain pile of code, this all broke down when The only sensible way out of the creaking pile of code once and for all was to rely on a solid library for parsing CSS, hence CSS tree. This also made it possible to compile cosmetic filters outside the browser environment, as is required for MV3 since filters are pre-compiled in Nodejs. Frankly, after almost |
Yeah, I wanted to follow-up in the discussion, but you removed your reply before I got back online so I thought you perhaps changed your mind about at least some part of my message.
True, but I originally ran into the issue when working with an
That's fine, but since |
|
Related feedback: - uBlockOrigin/uBlock-issues#2442 (comment)
That wasn't actually what I meant, but I'm glad this led you to finding this issue. What I meant was that while this will fail |
Ok, that is weird, I will look into this. (actually off the top of my head I think I know why this is happening, this needs fixing) |
Related issue: - uBlockOrigin/uBlock-issues#2442 These invalid pseudoclass operators were still seen as valid when mixed with procedural pseudoclass operators.
Sometimes I am more tired than usual and I see any task as being a mountain. Looking at this again, I think it's feasible to validate pseudo-classes using the list at https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes and reject anything not in there. |
Experimental stuff can be problematic, like https://blog.shahednasser.com/how-to-style-a-video-player-and-create-a-custom-player/#video-pseudo-element-selectors People asked for this earlier. |
These are pseudo-elements, I wouldn't touch these for now (CSSTree distinguishes these from pseudo-classes), and if ever I want to address them I would probably just ignore trying to validate peudo-elements prefixed with |
Chromium pseudo-classes #1247
(but I don't implemented this in Polish Annoyance Filters at all to today so mabye nobody use after fix) |
|
Polish Annoyance Filters have if: but I don't use gwarser script to research whole public filter lists. |
Related issue: - uBlockOrigin/uBlock-issues#2442 Cosmetic filters with unknown plain CSS pseudo-classes or unknown plain CSS pseudo-elements will be rejected, except for pseudo-classes/pseudo-elements which start with a `-`.
Maybe not the right place, but didn't want to create a new issue over such a small thing.
It now requires the use of the asterisk Is that by mistake or is it necessary due to some change and we should document it somewhere? Edit: It seems to be happening with all procedural filters (e.g. |
It's a regression due to gorhill/uBlock@fbc7a0e0ae. |
Discussed in #2440
Originally posted by u-RraaLL January 3, 2023
Before CSSTree, if I made a mistake with a pseudo class - e.g. a typo, the whole line would be invalidated. Now, the editors will accept anything that doesn't match the name of a procedural filter or an action operator <- these will throw errors until properly finished e.g.
:remove
->:remove()
,:matches-path
->:matches-path(/^/$/)
.This, however, will not throw any errors in "My filters"
:matchess-path(/^/$/)
. It will in Picker, though, which, I'm guessing, verifies the presence of brackets better.Invalid pseudo classes don't throw errors in neither of the places. They just won't have a match, which in Picker's case will usually prevent creation of the filter.
At first I thought Picker would accept
##a, b:randomstringhere
, allowing for matches ora
, but it seems it looks at the invalid pseudo classes in the procedural manner##a, b:has(c)
, not finding a match for either.It will still accept them if placed inside
:is()
,:where()
or:matches()
though. Which makes sense since they're using forgiving selectors list. So I understand the errors won't be thrown for these, but I do think they should be thrown in the other cases.I probably should've filed it as a bug report, but I'd be forced to lie on the template to send it in.
The text was updated successfully, but these errors were encountered: