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

Can't use set-constant.js multiple times for same parent property #156

Closed
8 tasks done
hawkeye116477 opened this issue Aug 9, 2018 · 27 comments
Closed
8 tasks done
Labels
bug Something isn't working fixed issue has been addressed

Comments

@hawkeye116477
Copy link

hawkeye116477 commented Aug 9, 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

Set-constant.js doesn't work for subdomains.

A specific URL where the issue occurs

[A specific URL is MANDATORY for issue happening on a web page, even if it happens "everywhere"]
https://wiadomosci.wp.pl/

Steps to Reproduce

For example, add this:

wp.pl##script:inject(set-constant.js, WP.crux.set, noopFunc)
||std.wpcdn.pl/wpjslib/*/wpjslib-chunk-notification.js

Then go to wiadomosci.wp.pl and you should not see GDPR message with blur, but it's here. But if you add wiadomosci.wp.pl##script:inject(set-constant.js, WP.crux.set, noopFunc), then everything is ok.

Your environment

  • uBlock Origin version: 1.16.14
  • Browser Name and version: Chromium 68.0.3440.75
  • Operating System and version: Manjaro 17.1.11 Hakoila
@hawkeye116477 hawkeye116477 changed the title Set-constant.js don't work for subdomains Set-constant.js doesn't work for subdomains Aug 9, 2018
@uBlock-user
Copy link
Contributor

uBlock-user commented Aug 9, 2018

GDPR message with blur

Can't reproduce. I don't see any GDPR msg with blur.

noopFunc is also successfully applied as per console -

@uBlock-user uBlock-user added the unable to reproduce cannot reproduce the issue label Aug 9, 2018
@hawkeye116477
Copy link
Author

hawkeye116477 commented Aug 9, 2018

If you test with Polish Filter, then you must also test previous version without that long filter open.fm,dobreprogramy.pl,www.wp.pl,wiadomosci.wp.pl,sportowefakty.wp.pl,money.pl,kobieta.wp.pl,gwiazdy.wp.pl,portal.abczdrowie.pl,parenting.pl,moto.wp.pl,tech.wp.pl,horoskop.wp.pl,gry.wp.pl,opinie.wp.pl,turystyka.wp.pl,tv.wp.pl,morizon.wp.pl,komorkomania.pl,gadzetomania.pl,fotoblogia.pl,finanse.wp.pl,pudelek.pl##script:inject(set-constant.js, WP.crux.set, noopFunc) 😄 Also GDPR message may be geolocked.

@gwarser
Copy link

gwarser commented Aug 9, 2018

I cannot reproduce with or without POL filter list.

@gorhill
Copy link
Member

gorhill commented Aug 9, 2018

Unable to reproduce:

a

The proper way to make the case that set-constant.js does not work is not by looking at web page behavior, it's by stepping in code and to show set-constant.js is not being executed. I confirm it is being executed. If the filter does not work after all, it's a filter issue.

@uBlock-user
Copy link
Contributor

uBlock-user commented Aug 9, 2018

If you test with Polish Filter

Then it's a filterlist issue, not a uBO issue. Investigate the cause on your end by disabling all other extensions and reseting to default settings.

Also GDPR message may be geolocked.

The only way I can reproduce the GDPR msg is if I remove the filters you suggested in the STR and refresh the page, so not geolocked either.

@hawkeye116477
Copy link
Author

hawkeye116477 commented Aug 9, 2018

@uBlock-user I tested with default settings and disabled other extensions. If I didn't do that, then I wouldn't check it 😄 But strange is that, I tested again and now it works correct.
But @F4z told me, that he still reproduce that.

@gorhill
Copy link
Member

gorhill commented Aug 9, 2018

But @F4z told me, that he still reproduce that.

He needs to make the case that the scriptlet is not executing, not that the page behave one way or another. Scriptlets are subject to timing issues, moreso depending on one's environment. For example, the more extensions installed which inject content scripts, the more chance uBO's scriptlets will be injected later, etc. In any case, the important point here is to provide evidence set-constant.js itself does not execute.

@uBlock-user uBlock-user added the invalid not a uBlock issue label Aug 9, 2018
@F4z
Copy link

F4z commented Aug 9, 2018

First screenshot with wp.pl##script:inject(set-constant.js, WP.crux.set, noopFunc) only, second screenshot when I added wiadomosci.wp.pl##script:inject(set-constant.js, WP.crux.set, noopFunc).

First screenshot

image

Second screenshot

image


It's not important to me, so if you can't reproduce it then this issue can be closed.

@gorhill
Copy link
Member

gorhill commented Aug 9, 2018

so if you can't reproduce

After I enabled POL, I can reproduce the GDPR warning. However after I disabled POL, I confirm that set-constant.js is executed, and I get the warning with both wp.pl or wiadomosci.wp.pl version of the filter:

a

@gorhill
Copy link
Member

gorhill commented Aug 9, 2018

How about:

wp.pl##script:inject(cookie-remover.js, STabid)

Seems to work on my side.

@F4z
Copy link

F4z commented Aug 9, 2018

Thank you for your answer, I checked it once again and now this rule - wp.pl##script:inject(set-constant.js, WP.crux.set, noopFunc) - works correctly, it's strange, because I didn't change anything.

@F4z
Copy link

F4z commented Aug 13, 2018

One more question, I disabled Polish filter list and added these two rules:
pilot.wp.pl##script:inject(set-constant.js, WP.crux.sealed, falseFunc)
pilot.wp.pl##script:inject(set-constant.js, WP.crux.set, noopFunc)
then opened this website - https://pilot.wp.pl/tv and only (the second) one of these rules works (please look on a screenshot).
Is it by design, bug or something wrong on my end?

Screenshot

image

@gorhill gorhill reopened this Aug 13, 2018
@gorhill
Copy link
Member

gorhill commented Aug 14, 2018

I see what the problem is.

@gorhill gorhill removed invalid not a uBlock issue unable to reproduce cannot reproduce the issue labels Aug 14, 2018
@uBlock-user uBlock-user added the bug Something isn't working label Aug 14, 2018
gorhill added a commit to gorhill/uBlock that referenced this issue Jul 8, 2019
Make sure the parser is safely compatible with old
resources format -- for those users still using
custom resources (via `userResourcesLocation`).

Prepare code for future fix to
<uBlockOrigin/uBlock-issues#156>:

This commit introduces a new private Map() object,
`uBOSafe`, accessible by all injected scriptlets. This
private safe can be used to store data which can be shared
with different scriptlets. The idea is for scriptlets to
use that safe to graciously deal with the need to install
multiple listeners for the same property.
gorhill added a commit to gorhill/uBlock that referenced this issue Jul 11, 2019
Since uBlockOrigin/uBlock-issues#156
won't be fixed in next release, no need to ship
with code which will be unused, and anyways only once
the fix is worked on will it be clear exactly what needs
to be used by scriptlets to deal harmoniously with
property listener collisions.
@prateekrastogi

This comment has been minimized.

gorhill added a commit to gorhill/uBlock that referenced this issue Jul 19, 2020
Related issues:
- uBlockOrigin/uBlock-issues#156
- uBlockOrigin/uBlock-issues#1162

Take into account that a trapped property may have been
already trapped, and if so honour previous trapper
getter/setter.
@gorhill gorhill changed the title Set-constant.js doesn't work for subdomains Can't use set-constant.js multiple times for same parent property Jul 19, 2020
@uBlock-user uBlock-user added the fixed issue has been addressed label Jul 19, 2020
@uBlock-user uBlock-user removed the fixed issue has been addressed label Oct 12, 2020
gorhill added a commit to gorhill/uBlock that referenced this issue Oct 12, 2020
Related feedback:
- uBlockOrigin/uBlock-issues#156 (comment)

Additionally, while investigating the issue I removed
code which is no longer needed since content scripts
are now injected in `about:blank` frames since 1.29.0.
@gorhill
Copy link
Member

gorhill commented Oct 12, 2020

Actually, it just occurred to me that I can simply prevent the targeted property itself to not be configurable while allowing the parent properties leading to the target property to be configurable so as to allow trapping multiple times the same chain of properties (which is what the issue here is about).

gorhill added a commit to gorhill/uBlock that referenced this issue Oct 12, 2020
@gwarser
Copy link

gwarser commented Oct 12, 2020

Fixed according to AdguardTeam/AdguardFilters#65244 (comment)

@gwarser
Copy link

gwarser commented Oct 15, 2020

@gorhill there seems to be one more corner case when one list redefines as null property set by other list as undefined (or vice-versa). Object.defineProperty throws, because property is not configurable (as far as I can understand when stepping through code).

Case is AdguardTeam/AdguardFilters#65519

Add to My filters:

thingiverse.com##+js(set-constant, blockedElement.className, null)
thingiverse.com##+js(set-constant, blockedElement.className, undefined)

Open: https://www.thingiverse.com/thing:2873324.

cc: @krystian3w


app.bundle.js?1602608340:2 TypeError: Cannot redefine property: className
    at Function.defineProperty (<anonymous>)
    at trapProp (<anonymous>:208:16)
    at trapChain (<anonymous>:227:13)
    at Object.setter (<anonymous>:265:21)
    at set (<anonymous>:220:25)
    at detected (app.bundle.js?1602608340:2)
    at pr (app.bundle.js?1602608340:2)
    at app.bundle.js?1602608340:2
    at ys (app.bundle.js?1602608340:2)
    at Ul (app.bundle.js?1602608340:2)

I don't understand - it works with "", but does not with any other constant. I thought it was only about null and undefined :(

@gorhill
Copy link
Member

gorhill commented Oct 15, 2020

To fix this would take a lot of non-trivial code, not sure it's worth it if this can be reasonably be fixed in filter lists. Maybe that non-trivial code will occur in some future but for now it's far off.


Alright, let me investigate first rather than assume I know exactly what is happening.

@gorhill
Copy link
Member

gorhill commented Oct 15, 2020

it works with "", but does not with any other constant

"" is not a valid constant, you need to use '', your filter ended up being discarded by using "".

And yes, after investigation, I confirm what I said above.

@addisr
Copy link

addisr commented Oct 19, 2020

@gorhill I think this broke this rule. Kinda. Property seems overridden but console says Uncaught TypeError: can't redefine non-configurable property "adblock" and some features of the website are broken.

@gorhill
Copy link
Member

gorhill commented Oct 19, 2020

@addisr Thanks for feedback. I can reproduce, and I have a fix. Now I wonder if this warrants an emergency fix.

gorhill added a commit to gorhill/uBlock that referenced this issue Oct 19, 2020
Related feedback:
- uBlockOrigin/uBlock-issues#156 (comment)

When the client code assigned a variable to itself, this
would cause the scriptlet to try to re-trap already
trapped properties.
@uBlock-user
Copy link
Contributor

Now I wonder if this warrants an emergency fix.

CNBC is now broken - https://www.reddit.com/r/uBlockOrigin/comments/jeei8n/ublockfilters_is_breaking_cnbc/

@gwarser
Copy link

gwarser commented Oct 20, 2020

Isn't gorhill/uBlock@2b262b2 actually fixing what I said above in #156 (comment) ?


In tree: gorhill/uBlock@5de0ce9

@krystian3w

This comment has been minimized.

@gorhill
Copy link
Member

gorhill commented Oct 20, 2020

actually fixing what I said above

I expect this will prevent the throwing at the console, through it won't cause the second filter to work. The more serious issue though is that it was breaking pages doing something like var obj = obj || {}; which should definitely not happen.

JustOff pushed a commit to gorhill/uBlock-for-firefox-legacy that referenced this issue Dec 21, 2020
Related issues:
- uBlockOrigin/uBlock-issues#156
- uBlockOrigin/uBlock-issues#1162

Take into account that a trapped property may have been
already trapped, and if so honour previous trapper
getter/setter.
JustOff pushed a commit to gorhill/uBlock-for-firefox-legacy that referenced this issue Dec 21, 2020
JustOff pushed a commit to gorhill/uBlock-for-firefox-legacy that referenced this issue Dec 21, 2020
JustOff pushed a commit to gorhill/uBlock-for-firefox-legacy that referenced this issue Dec 21, 2020
Related feedback:
- uBlockOrigin/uBlock-issues#156 (comment)

When the client code assigned a variable to itself, this
would cause the scriptlet to try to re-trap already
trapped properties.
mneunomne pushed a commit to mneunomne/AdNauseam that referenced this issue Mar 8, 2021
Related feedback:
- uBlockOrigin/uBlock-issues#156 (comment)

Additionally, while investigating the issue I removed
code which is no longer needed since content scripts
are now injected in `about:blank` frames since 1.29.0.
mneunomne pushed a commit to mneunomne/AdNauseam that referenced this issue Mar 8, 2021
mneunomne pushed a commit to mneunomne/AdNauseam that referenced this issue Mar 8, 2021
Related feedback:
- uBlockOrigin/uBlock-issues#156 (comment)

When the client code assigned a variable to itself, this
would cause the scriptlet to try to re-trap already
trapped properties.
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

9 participants