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

Nested !#if/!#endif directives not evaluated properly #270

Closed
8 tasks done
krystian3w opened this issue Oct 15, 2018 · 10 comments
Closed
8 tasks done

Nested !#if/!#endif directives not evaluated properly #270

krystian3w opened this issue Oct 15, 2018 · 10 comments
Labels
bug Something isn't working fixed issue has been addressed

Comments

@krystian3w
Copy link

krystian3w commented Oct 15, 2018

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

Two conditions for limiting the operation of filters do not work well, the second condition is may not interpreted.

uBlockOrigin/uAssets#3482 - where used two conditions.

A specific URL where the issue occurs

https://www.google.com/search?q=search

Steps to Reproduce

  1. Open expample website

  2. In my filters panel put expample conditions:

    !#if env_firefox
    !#if env_mobile
    google.*###main > div
    !#endif
    !#endif
    

    and save.

  3. Refresh website - almost all div should be hidden.

  4. The second condition is somewhat ignored and cuts out the content despite the incompatibility of the platfrom.

Expected behavior:

The second condition should be included.

Actual behavior:

The second condition is not included?

Your environment

  • uBlock Origin version: 1.17.0
  • Browser Name and version: Firefox 62.0.2
  • Operating System and version: Windows 7 Professional x64 PL language edditon.
@uBlock-user
Copy link
Contributor

uBlock-user commented Oct 15, 2018

Duplicate of #183

@uBlock-user uBlock-user marked this as a duplicate of #183 Oct 15, 2018
@uBlock-user uBlock-user added the duplicate This issue or pull request already exists label Oct 15, 2018
@gorhill
Copy link
Member

gorhill commented Oct 15, 2018

Does not seem to be a duplicate, there is no syntax error in the directives -- which is what #183 was about.

@gorhill gorhill reopened this Oct 15, 2018
@uBlock-user uBlock-user marked this as not a duplicate of #183 Oct 15, 2018
@gorhill gorhill removed the duplicate This issue or pull request already exists label Oct 15, 2018
@uBlock-user
Copy link
Contributor

uBlock-user commented Oct 15, 2018

google.*###main > div filter doesn't get applied, is that expected response ? My Filters count remains 0 out of 0. Nvm, I was testing on Chromium.

@gorhill
Copy link
Member

gorhill commented Oct 15, 2018

If I understand correctly he is saying all divs end up being hidden, while this should not be the case if not using Firefox for Android.

@uBlock-user uBlock-user added the Firefox specific to Firefox label Oct 15, 2018
@uBlock-user
Copy link
Contributor

uBlock-user commented Oct 15, 2018

search bar along with Google logo doesn't get hidden except that everything else is hidden.

@uBlock-user
Copy link
Contributor

The second condition should be included.

The second condition won't get fulfilled if you're not on Firefox for Android, so I don't see the issue with that.

@krystian3w
Copy link
Author

krystian3w commented Oct 15, 2018

If I understand correctly he is saying all divs end up being hidden, while this should not be the case if not using Firefox for Android.

Yes.

search bar alongwith Google logo doesn't get hidden except that everything else is hidden.

I did not check this out, I noticed that it started hidding div[data-hveid] out in the simulator with mobile UA activated, so I preferred to report.


As for the problem, I even recreated it in Opera 56 - it also hides most of the elements and is the top browser bar.

!#if env_chrome
!#if env_mobile
google.*###main > div
!#endif
!#endif

/

!#if env_chromium
!#if env_mobile
google.*###main > div
!#endif
!#endif
image

but uBO do not support officially Mobile Yandex browser.


The second condition won't get fulfilled if you're not on Firefox for Android, so I don't see the issue with that.

Then rely on the perfection of the filter.

@uBlock-user
Copy link
Contributor

@gorhill Do all preparsing directives have to be true for the filter to apply ?

@gorhill
Copy link
Member

gorhill commented Oct 15, 2018

Yes.

However looking at the code, I see that directives which evaluate to false will be ignored if contained in a directive which evaluates to true -- this is a bug. I can't remember what was my thinking when I wrote that code, but my answer to @grenzor in #183 says that I was expecting the code to deal properly with !#if within !#if.

@uBlock-user uBlock-user added bug Something isn't working and removed Firefox specific to Firefox labels Oct 15, 2018
gorhill added a commit to gorhill/uBlock that referenced this issue May 18, 2019
@gorhill gorhill changed the title Two conditions wrongly interpreted on the computer Nested !#if/!#endif directives not evaluated properly May 18, 2019
@uBlock-user uBlock-user added the fixed issue has been addressed label May 19, 2019
@krystian3w
Copy link
Author

krystian3w commented May 26, 2019

Possible add in the feature this syntax:

!#if (!adguard_ext_android_cb && !adguard_ext_safari && !adguard_app_ios)

similar proposed by @mapx-


!#if !adguard_ext_android_cb 
!#if !adguard_ext_safari 
!#if !adguard_app_ios

! filter for modern uBlock Origin and AdGuard Adblocker / AdGuard APP (macOS, Windows, Android).
! "modern" - support `:style()` filters.

!#endif
!#endif
!#endif

JustOff added a commit to gorhill/uBlock-for-firefox-legacy that referenced this issue Jan 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed issue has been addressed
Projects
None yet
Development

No branches or pull requests

3 participants