Comments (20)
Ok, well, today-I-learned. I could have just tried it at the console... I will need to fix in uBO.
from nanocore.
If I understood right:
elem > :op(...)
andelem > *:op(...)
means apply the operatorop
to immediate children ofelem
elem > * :op(...)
means apply the operatorop
to any (grand)children of any immediate children ofelem
elem :op(...)
means apply the operatorop
to any (grand)children ofelem
from nanocore.
@ameshkov FYI, syntax errors in the spyware filter:
gopro.com#$#body[class^="smartling-] { padding-top: 60px!important; }
xtreme.ws##.topBorder > table[width="100%"][height="205"]body > #top
First one missing other double-quote, second one is invalid selector.
from nanocore.
@ameshkov I'm not sure if this works in Adguard, but it's rejected by uBO (and Nano) and looks kind of weird. The scope operator doesn't point to anything, and immediately followed by :match-css
. Is that intended?
from nanocore.
The scope operator doesn't point to anything, and immediately followed by :match-css. Is that intended?
Yes, this is a valid pseudo-class usage. @gorhill, looks like a bug to me.
Also, shouldn't this be #$#?
Absolutely, thx for pointing this out!
from nanocore.
Yes, this is a valid pseudo-class usage. @gorhill, looks like a bug to me.
You need to use a *
: *:matches-css(...)
. Pseudo operators are meant to mimick what could be a valid CSS selector, and without a prefix this wouldn't work even for valid CSS selectors. Example: .headeliner > :not(...)
is not a valid selector, or assuming :has
is implemented by browser vendors, .headeliner > :has(...)
wouldn't be valid selector. .headeliner > *:not(...)
and .headeliner > *:has(...)
are however valid.
from nanocore.
Example: .headeliner > :not(...) is not a valid selector
from nanocore.
@ameshkov So the *
is implicit? Then it would be a duplicate of the rule below?
from nanocore.
@ameshkov So the * is implicit?
Yes, it is.
Then it would be a duplicate of the rule below?
As I understand, it's not.
In the rule below it means that there is an intermediate element between .page-form
and :matches-css
.
from nanocore.
Some Linter issues:
-
||example.com^$~document
discards the filter and gives a cannot be negated error, butdocument
can be negated and the filter should be valid -
@||example.com^
no error is given but filter is missing a@
at the start -
||example.com^,domain=example2.com
no error is given but it's an invalid filter -
||example.com^$third-party,$image
accidental use of$
for image makes it invalid -
x||example.com^
becomes invalid filter due tox
, usually due to some typo or accidental copying -
example.blogspot.*##element
error should be given whenever trying to match partial public suffix. Might also be applicable to other static filter syntax -
||example.com^$third-party,~image,image
looks like image block takes precedence over negated. Not sure if some error could be given for this kind of accidental double syntax
from nanocore.
@grenzor
The linter is always right when it comes to showing errors since it uses the exact same parsing engine. If it shows error, then the filter is rejected, if it does not show error, then the filter is accepted, although how will the filter behave is another question.
By design, the linter will never show error if the filter is accepted, but I do agree warnings should be shown for some of these cases. I'll work on that later.
I think these should generate warning:
@||example.com^
example.blogspot.*##element
||example.com^$third-party,~image,image
The error in ||example.com^,domain=example2.com
and ||example.com^$third-party,$image
are pretty obvious from syntax highlighting, so no extra linter warning is needed. Also, I think x||example.com^
is really unlikely to happen.
from nanocore.
The error in
||example.com^,domain=example2.com
and||example.com^$third-party,$image
are pretty obvious from syntax highlighting
They may be easy to spot if you have a few filters, but for someone with 100s/1000s of their own filters it is not easy at all. It's easier for the user to scroll down and just look at the sidebar for an icon of error or warning than manually checking each line's color syntaxing.
from nanocore.
@grenzor
I think you should be writing one filter at a time, and not 1000 then test together. Beside, even if the filter doesn't contain obvious mistake, it doesn't mean it'll work.
from nanocore.
I agree, but my use case was someone with already written filters in uBO who then imported them into Nano.
from nanocore.
@grenzor
You should still have validated each filter when you wrote them to make sure they actually work.
from nanocore.
Is this clear enough? Or I should still dispatch a linter warning?
from nanocore.
Showing a linter warning will be better imo.
from nanocore.
@jspenguin2017 thank you, we'll fix them soon!
from nanocore.
Pretty obvious from highlighting@@||example.com^generichide
- Forgot$
It is quite rare that^
is used just to match/
, 9 out of 10 times it's a mistake.
Detection logic: If a filter has one^
and no$
, and^
is not at the very end, then insert$
right after^
, if the filter is still (or still seems) valid, then dispatch a warning.Preprocessors will be highlighted as keywords!#incluuuude
- Misspelled preprocessor (need to investigate how preprocessor is handled forMy filters
)
Preprocessor are like comments, but has special meaning when spelled correctly.
Detection logic: If a line starts with! #
, then dispatch a warning (extra space). Otherwise, if a line starts with!#
but is not a valid preprocessor directive, dispatch a warning.
from nanocore.
Need to investigate how the redirect feature works with RegExp rules. With recent change (uBlockOrigin/uBlock-issues#977), the redirect portion of RegExp rules is no longer rejected.
Update: Moved to a new issue: #352
from nanocore.
Related Issues (20)
- Use `! Title` in the filters HOT 3
- Sometimes the bottom toolbar of the popup panel is pushed to the right
- Prepare for 1.27.10 HOT 1
- [Feature Request] Protect Nano Adblocker With Password HOT 2
- Question : do we need to enable “Nano Defender Integration” ? HOT 1
- Nano adblocker causes CPU spike under certain conditions HOT 4
- "A network error prevented the resource from being updated" HOT 2
- Prepare for 1.29.2 HOT 9
- Stop updating MDLMirror
- Investigate behavior of redirect options with RegExp rules
- Custom Lists Are Automatically Added HOT 2
- Consider moving `immediateHiddenSettings` back to `localStorage`
- uBO error with parsing old ##script:inject syntax format in nanobase list HOT 1
- Prepare for 1.29.4 HOT 3
- Filter Names HOT 2
- Can't update or add filters HOT 4
- Adblock Warning Removal List no longer supported on uBlock Origin HOT 6
- These custom filters don't work now in Facebook's NEW UI. HOT 1
- Does Nano Adblocker allow hosts to make revenue? HOT 4
- [Announcement] Recent and upcoming changes to the Nano projects HOT 92
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nanocore.