-
Notifications
You must be signed in to change notification settings - Fork 335
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
Pre-processor directives for filters #917
Comments
@gorhill check this out plz, would you like to change something? As I understand, @mat41997 and @hawkeye116477 are okay with this solution. |
@mat41997 frankly, I don't understand how do you manage to live with a single file. Most of the large filters I know split the rules into multiple files just because it's easier to support it this way: |
@ameshkov Looks all good to me, thanks for fleshing out this. I started implementing the For the
I think for simplicity it should be the full path, but for the same origin as the main list. Personally I accept full URL, but the origins have to match. If no full URL is given, I treat as full path to which the main origin is prepended. Relative paths can be rather complicated to deal with, and having to specify full path shouldn't be such a burden on filter list maintainers, while keeping the code simpler. |
As I understand, this is almost enough to support relative paths:
XHR will understand a path like that properly: |
@ameshkov We want to have one list with rules for Adblock and rules which Adblock have problems with it, because of no scroll for example. So rules should be commented to Adblock not use it. But for beginning it can be just |
@hawkeye116477 Having to comment every single filter does not make sense to me. The
Who is "we"? |
I propose |
|
Sure, by the number of include directives. |
Then wouldn't it be better for everybody to merge lists to one on server side, not on client side? Users wouldn't have to download multiple files and your servers wouldn't have to answer to multiple net requests. include relative paths should not be used in popular filterlists. |
Ideally, it would indeed. However, unfortunately, not everyone possesses the necessary knowledge to automate building different filters for different ad blockers. Also, the suggested |
Also many lists have multiple mirrors with identical content. Maybe another directive |
Guys, I find it quite important to keep development incremental and to do as less as possible, just enough to achieve the current goal. Let's first see how it goes with a single include directive @gorhill has implemented. |
As a bystander and a happy user of uBO, I am less than thrilled about the include directive from a security perspective (and will defer upgrading to uBO 23 for a while). If a list maintainer's site is compromised or an HTTP site is MITM'ed, users' browsers can be forced to do requests to unknown sites, possibly opening them up to drive-by attacks. Just my 2c. |
Another consideration: GNU Moving towards adding Turing-completeness to adblock lists looks a bit ... excessive. |
The implementation in uBO does not allow cross-origin requests, the embedded filter lists have to be on the same server. If not, it is rejected. |
Also, note that if a server is compromised, an attacker may as well redirect the request for the main list to another server, so if this is what worries you, you will have to prevent your blocker from downloading all lists from any server. In any case, as said above, uBO reject cross-origin requests for embedded filter lists. |
@gorhill - thanks for the clarification, upgrading to 1.14.23 now. From an outsider's viewpoint, this restriction is important enough to land in the spec. |
It is there:
|
I would already need now an ability to negate -- not sure what is best:
Or:
Or whatever else is deemed better. |
I vote for |
@gorhill I am for supporting boolean operators, it'd be much more helpful to filters maintainers. Eval-based implementation is rather trivial. Although, for the production-ready we should use a simple expressions parser instead:
|
A bit of a thread hijack, but wasn't sure where else to ask. Does a rule starting with |
@collinbarrett filter metadata looks like a comment ( |
Merge in EXTENSIONS/browser-extension from feature/AG-8668 to feature/AG-2737 Squashed commit of the following: commit b275da0 Merge: b0b40c9 34fa747 Author: Vladimir Zhelvis <[email protected]> Date: Mon Jun 21 15:46:10 2021 +0300 Merge branch 'feature/AG-2737' into feature/AG-8668 commit b0b40c9 Author: Vladimir Zhelvis <[email protected]> Date: Mon Jun 21 14:39:01 2021 +0300 add comments, separate conditional rendering in request preview component commit 5fea753 Author: Vladimir Zhelvis <[email protected]> Date: Mon Jun 21 13:47:32 2021 +0300 refactoring request preview state machine, fix styles
@gorhill any idea why EasyList does not use these directives? For example, EasyList could have two versions of the same filter:
uBlock Origin could ignore the text in the I see people asking for features in Adblock Plus that the developers will almost certainly never implement (e.g. adblockpluscore#323). One more thing that might help is if two
This way Adblock Plus would treat the filter with the |
EasyList has already started using uBO syntax, for example in https://secure.fanboy.co.nz/fanboy-cookiemonster.txt, which has a
Probably the best approach since it groups together filters targeted at a specific platform. For ABP-specific filters explictly not meant for uBO, they can already use I consider |
Based on this discussion:
gorhill/uBlock#3331
We should provide multiple pre-processor directives that can be used by filters maintainers to improve compatibility with different ad blockers.
Syntax
!#if
,!#endif
-- filters maintainers can use these conditions to supply different rules depending on the ad blocker type.condition
-- just like in some popular programming languages, pre-processor conditions are based on constants declared by ad blockers. Ad blocker authors define on their own what exact constants do they declare.!#include
-- this directive allows to include contents of a specified file into the filter.Conditions
When an adblocker encounters an
!#if
directive, followed eventually by an!#endif
directive, it will compile the code between the directives only if the specified condition is true. Condition supports all the basic logical operators.Example:
Including a file
The
!#include
directive supports only files from the same origin to make sure that the filter maintainer is in control of the specified file. The included file can also contain pre-processor directives (even other!#include
directives).Ad blockers should consider the case of recursive
!#include
and implement a protection mechanism.Examples
Filter URL:
https://example.org/path/filter.txt
Remarks
!#if
is a valid directive, while!# if
is not.AdGuard-specific
What constants should we declare
adguard
-- Declared always. Lets maintainers know that this is one of AdGuard products. Should be enough in 95% of cases.Product-specific constants for some rare cases (or not so rare, thx Safari):
adguard_app_windows
-- AG for Windowsadguard_app_mac
-- AG for Macadguard_app_android
-- AG for Androidadguard_app_ios
-- AG for iOSadguard_ext_chromium
-- AG browser extension for Chromeadguard_ext_firefox
-- AG browser extension for Firefoxadguard_ext_edge
-- AG browser extension for Edgeadguard_ext_safari
-- AG browser extension for Safariadguard_ext_opera
-- AG browser extension for Operaadguard_ext_android_cb
-- AG content blocker for Samsung/YandexThe text was updated successfully, but these errors were encountered: