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

Add Support for AdGuard Special Case Pre-Processor Directives #1205

Closed
4 of 8 tasks
yourduskquibbles opened this issue Aug 12, 2020 · 4 comments
Closed
4 of 8 tasks
Labels
enhancement New feature or request fixed issue has been addressed

Comments

@yourduskquibbles
Copy link

yourduskquibbles commented Aug 12, 2020

Prerequisites

  • I verified that this is not a filter issue
  • This is not a support issue or a question
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue
    • Your issue may already be reported.
  • I tried to reproduce the issue when...
    • uBlock Origin is the only extension
    • uBlock Origin with default lists/settings
    • using a new, unmodified browser profile
  • I am running the latest version of uBlock Origin
  • I checked the documentation to understand that the issue I report is not a normal behavior

Description

From AdGuard's KB Allowed Pre-Processor Directive List they use additional AdGuard product specific directives in special cases that uBO doesn't recognize.

I'd like to use the adguard_app_ios directive to conditionally load a sublist in Web Annoyances Ultralist only in the iOS AdGuard environment (Due to iOS not allowing CSS modifications and needing to remove some companion filters that make the page incorrect render when the CSS rules don't get loaded) but uBO doesn't recognize the adguard_app_ios directive and then loads the sublist wrapped in directive not recognized that I only want to conditionally load when it is iOS AdGuard envionment.

The same behavior is observed if when only loading the sublist directly - The filters wrapped in the unrecognized directive gets loaded because uBO just ignores the directive rather than recognize the directive as false and treat everything until the closing !#endif as not to be loaded.

  1. If uBO encounters a directive it doesn't understand does it make more sense to throw out all content between the invalid directive and the closing !#endif?

  2. Is it possible to add additional directives that uBO will recognize to mirror AdGuard used directives? I can elaborate more on what issue this specific sublist fixes (screenshots, video) if you'd like.

adguard_app_mac -- AG for Mac
adguard_app_android -- AG for Android
adguard_app_ios -- AG for iOS
adguard_ext_safari -- AG browser extension for Safari
adguard_ext_android_cb -- AG content blocker for Samsung/Yandex

Related:
yourduskquibbles/webannoyances#241

A specific URL where the issue occurs

N/A

Steps to Reproduce

  1. Add custom list https://raw.githubusercontent.com/yourduskquibbles/webannoyances/master/ultralist.txt
  2. Observe Logger is loading sublist filters/adguard_app_ios_exclusion_filters.txt wrapped in invalid directive adguard_app_ios
  3. Unsubscribe from custom list https://raw.githubusercontent.com/yourduskquibbles/webannoyances/master/ultralist.txt
  4. Add custom list https://raw.githubusercontent.com/yourduskquibbles/webannoyances/master/filters/adguard_app_ios_exclusion_filters.txt
  5. Observe logger loads the custom filters wrapped in invalid directive adguard_app_ios

Expected behavior:

uBO ignores everything inside of invalid !#if directive until closing !#endif

Actual behavior:

uBO ignores only the 1 line of the invalid directive and proceeds to load content within the invalid !#if statement

Your environment

  • uBlock Origin version: 1.29.1b0
  • Browser Name and version: Firefox Nightly
  • Operating System and version:
@uBlock-user uBlock-user added the enhancement New feature or request label Aug 12, 2020
gorhill added a commit to gorhill/uBlock that referenced this issue Aug 13, 2020
@gorhill
Copy link
Member

gorhill commented Aug 13, 2020

If uBO encounters a directive it doesn't understand does it make more sense to throw out all content between the invalid directive and the closing !#endif?

No, this could cripple uBO's parsing of otherwise good filters if a list makes use of an unknown directives. Throwing away filters should be done only when the intent is clear and explicit. Imagine ABP coming up with pre-parser support and start to ask filter list maintainers to make use of them for whatever reasons, this could cause uBO to unduly throw away perfectly compatible filters.

@yourduskquibbles yourduskquibbles added the fixed issue has been addressed label Aug 13, 2020
@bogachenko
Copy link

bogachenko commented Aug 21, 2020

@gorhill The issue is not fully resolved, the combination of conditions does not work.

You can add to my filters and check it https://raw.githubusercontent.com/bogachenko/filterlist/personal/bogachenkoPF.txt

!#if (adguard_ext_safari || adguard_app_ios || adguard_ext_android_cb)
||google.com^
!#endif

|| or && for separate

!#if (adguard_app_android && adguard_app_ios)
||google.com^
!#endif

FAQ - https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#conditions

@gorhill
Copy link
Member

gorhill commented Aug 21, 2020

The issue as described is resolved. What you are asking is something unrelated to the original issue.

@bogachenko
Copy link

Why should I create the same type of topic with issue, when i can write here, in addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed issue has been addressed
Projects
None yet
Development

No branches or pull requests

4 participants