uBlockOrigin / uBlock-issues

This is the community-maintained issue tracker for uBlock Origin
https://github.com/gorhill/uBlock
950 stars 81 forks source link

yahoo.com: ads => CSSTree ? #2284

Closed troysjanda closed 2 years ago

troysjanda commented 2 years ago

Prerequisites

URL address of the web page

https://www.yahoo.com/

Category

ads

Describe the issue

steps to reproduce, 1) upate to latest dev version 2) add https://raw.githubusercontent.com/troysjanda/MyBlockLists/master/yahoocomplete.txt filterlist 3) purge and update filters 4) load yahoo.com

items blocked are no longer blocker, empty place holders. if using picker and selecting item to block on page refresh it reappears

Screenshot(s)

https://i.postimg.cc/c1Yp2DFs/error.png

Screenshot(s)

Configuration

```yaml uBlock Origin: 1.44.5b1 Firefox: 105 filterset (summary): network: 182825 cosmetic: 85006 scriptlet: 21141 html: 786 listset (total-discarded, last-updated): removed: plowe-0: null added: https://raw.githubusercontent.com/troysjanda/MyBlockLists/master/UBOXPI: 481-1, 5m https://raw.githubusercontent.com/troysjanda/MyBlockLists/master/yahoocomplete.txt: 512-0, 5m https://www.i-dont-care-about-cookies.eu/abp/: 25376-4, 5m adguard-spyware-url: 763-3, 6m block-lan: 44-0, 6m curben-phishing: 95457-4, 6m curben-pup: 193-0, 6m fanboy-social: 23364-9, 5m ublock-annoyances: 4846-9, 5m default: user-filters: 10-0, never ublock-filters: 33578-44, 6m ublock-badware: 4184-0, 6m ublock-privacy: 268-0, 6m ublock-abuse: 76-0, 6m ublock-unbreak: 1872-3, 6m ublock-quick-fixes: 241-0, 6m easylist: 62822-331, 6m easyprivacy: 30635-1195, 6m urlhaus-1: 6720-0, 6m filterset (user): [array of 10 redacted] trustedset: added: [array of 41 redacted] hostRuleset: added: [array of 3 redacted] modifiedUserSettings: advancedUserEnabled: true showIconBadge: false webrtcIPAddressHidden: true modifiedHiddenSettings: autoCommentFilterTemplate: none extensionUpdateForceReload: true filterAuthorMode: true filterOnHeaders: true updateAssetBypassBrowserCache: true userResourcesLocation: [redacted] supportStats: allReadyAfter: 566 ms maxAssetCacheWait: 257 ms popupPanel: blocked: 67 blockedDetails: yahoo.com: 37 advertising.com: 1 akamaized.net: 1 d1vl8wytztdz.cloudfront.net: 1 llnwd.net: 1 scorecardresearch.com: 3 yahoo.net: 3 yahoodns.net: 7 yimg.com: 13 ```
troysjanda commented 2 years ago

The new CSSTree is screwing up filters my yahoo list https://raw.githubusercontent.com/troysjanda/MyBlockLists/master/yahoocomplete.txt is not showing any invalid filters but yahoo is completely screwed up cant scroll, all the hidden/blocked stuff is not, empty placeholders are not hidden

mapx- commented 2 years ago

only when I add your list I get empty PH (FF, 1.44.5b1)

mapx- commented 2 years ago

@gorhill

gorhill commented 2 years ago

The front page looks fine to me with your list. I need to know how to reproduce.

Never mind, I can reproduce with Firefox, but not Chromium.

gorhill commented 2 years ago

Some help to find the filter causing this would be appreciated.


I think it's filters with ...:nth-of-type(...)

troysjanda commented 2 years ago

I have tried everything fix my list and I am reverting to 1.44.5b0 and it seems to fix everything I guess ill stop updating and stay at 1.44.5b0 CSSTree is really messing up my filters and since I use the picker to make the filters. this is my list https://raw.githubusercontent.com/troysjanda/MyBlockLists/master/yahoocomplete.txt I dislike the new CSSTree to be honesty Im at this point going to stay on 1.44.5b0

with the new 1.44.5b1 if using the picker to block or hide something it reappears even with purging cache I really at this point giving up trying to fix my filters. the empty place holders stay here is what Yahoo looks like https://i.postimg.cc/c1Yp2DFs/error.png I even starting a new yahoo list and still having issues with making filters and them staying hidden or blocked.

To be clear I use the picker to make filters and not an expert on looking for and making filter any other way.

mapx- commented 2 years ago

Yes, only those 2 :nth-of-type filters

troysjanda commented 2 years ago

www.yahoo.com##li.stream-grid-view_Fxg\(2\).stream-grid-view_Flxb\(1\/3\).My\(12px\).Pos\(r\).Bgc\(t\).js-stream-content.stream-item > .stream-grid-view_Fld\(c\).D\(f\).Pos\(r\).userintent-hidestrmitem_D\(n\) > .End\(0\).user-intent-options.T\(0\).Pos\(a\) > div > .has-wafer-click.has-toggle-click.wafer-toggle.userintentmgmt-panel.Ta\(c\) www.yahoo.com##.End\(12px\).user-intent-options.T\(0\).Pos\(a\) > div > .has-wafer-click.has-toggle-click.wafer-toggle.userintentmgmt-panel.Ta\(c\) > .has-wafer-click.has-fetch-click.C\(--pebble\).D\(b\).Td\(n\).Td\(n\)\:h.fetch-with-session-retry.wafer-fetch.Fill\(--dolphin\).userintent-panelbtn.userintentmgmt-panel\:h\>Fill\(\$streamBrandHoverClass\).Py\(0\).Pend\(0\).Pstart\(4px\).O\(n\)\:f.Bd\(n\).Pos\(r\) www.yahoo.com##.finance-ticker-fetch-success.stream-grid-view_Flxb\(1\/3\).My\(12px\).Pos\(r\).Bgc\(t\).js-stream-content.stream-item > .stream-grid-view_Fld\(c\).D\(f\).Pos\(r\).userintent-hidestrmitem_D\(n\) > .End\(0\).user-intent-options.T\(0\).Pos\(a\) > div > .has-wafer-click.has-toggle-click.wafer-toggle.userintentmgmt-panel.Ta\(c\) > .has-wafer-click.has-fetch-click.C\(--pebble\).D\(b\).Td\(n\).Td\(n\)\:h.fetch-with-session-retry.wafer-fetch.Fill\(--dolphin\).userintent-panelbtn.userintentmgmt-panel\:h\>Fill\(\$streamBrandHoverClass\).Py\(0\).Pend\(0\).Pstart\(4px\).O\(n\)\:f.Bd\(n\).Pos\(r\) www.yahoo.com##.End\(0\).user-intent-options.T\(0\).Pos\(a\) > div > .has-wafer-click.has-toggle-click.wafer-toggle.userintentmgmt-panel.Ta\(c\)

Are not working after a page refresh they appear back

www.yahoo.com##li.stream-grid-view_Fxg\(2\).stream-grid-view_Flxb\(1\/3\).My\(12px\).Pos\(r\).Bgc\(t\).js-stream-content.stream-item > .stream-grid-view_Fld\(c\).D\(f\).Pos\(r\).userintent-hidestrmitem_D\(n\) > .End\(0\).user-intent-options.T\(0\).Pos\(a\) > div > .has-wafer-click.has-toggle-click.wafer-toggle.userintentmgmt-panel.Ta\(c\) www.yahoo.com##.End\(12px\).user-intent-options.T\(0\).Pos\(a\) > div > .has-wafer-click.has-toggle-click.wafer-toggle.userintentmgmt-panel.Ta\(c\) > .has-wafer-click.has-fetch-click.C\(--pebble\).D\(b\).Td\(n\).Td\(n\)\:h.fetch-with-session-retry.wafer-fetch.Fill\(--dolphin\).userintent-panelbtn.userintentmgmt-panel\:h\>Fill\(\$streamBrandHoverClass\).Py\(0\).Pend\(0\).Pstart\(4px\).O\(n\)\:f.Bd\(n\).Pos\(r\) www.yahoo.com##.finance-ticker-fetch-success.stream-grid-view_Flxb\(1\/3\).My\(12px\).Pos\(r\).Bgc\(t\).js-stream-content.stream-item > .stream-grid-view_Fld\(c\).D\(f\).Pos\(r\).userintent-hidestrmitem_D\(n\) > .End\(0\).user-intent-options.T\(0\).Pos\(a\) > div > .has-wafer-click.has-toggle-click.wafer-toggle.userintentmgmt-panel.Ta\(c\) > .has-wafer-click.has-fetch-click.C\(--pebble\).D\(b\).Td\(n\).Td\(n\)\:h.fetch-with-session-retry.wafer-fetch.Fill\(--dolphin\).userintent-panelbtn.userintentmgmt-panel\:h\>Fill\(\$streamBrandHoverClass\).Py\(0\).Pend\(0\).Pstart\(4px\).O\(n\)\:f.Bd\(n\).Pos\(r\) www.yahoo.com##.End\(0\).user-intent-options.T\(0\).Pos\(a\) > div > .has-wafer-click.has-toggle-click.wafer-toggle.userintentmgmt-panel.Ta\(c\) www.yahoo.com##.wafer-destroyed.Va\(t\).D\(f\).Td\(n\).rapidnofollow.js-content-viewer www.yahoo.com##.W\(1\/4\)--maw1024.W\(1\/3\)

Also apprear to not work

troysjanda commented 2 years ago

https://user-images.githubusercontent.com/24624945/192118854-dc802d63-9100-4c93-a203-adee0a62e46e.PNG https://user-images.githubusercontent.com/24624945/192118856-b921b891-4f33-4d92-b300-8fde149b02eb.PNG

stuff not blocked, empty placeholders, pointed out with the yellow highlight

gorhill commented 2 years ago

The issue is nth, fixing, no need to add more information.

troysjanda commented 2 years ago

other non working filters listed above are not of the nth type, and seem to work under 1.44.1b0 and not the 1.44.1b1 with the new CSSTree.

troysjanda commented 2 years ago

maybe a toggle in advanced settings to switch between the CSSTree parser and the prior parser until such time as the bugs can be worked out.

gorhill commented 2 years ago

stuff not blocked, empty placeholders

I can't make anything of this without knowing the exact URL I have to visit to see the issue for myself.

troysjanda commented 2 years ago

on another note there are only 2 filters with the nth type in my list

and there is way more breakage that just those 2 filters as listed above

troysjanda commented 2 years ago

stuff not blocked, empty placeholders

I can't make anything of this without knowing the exact URL I have to visit to see the issue for myself.

YAHOO.COM

gorhill commented 2 years ago

An empty :nth-of-type() -- which is the issue I am fixing -- is not a valid selector, so it's going to cause other cosmetic filters in the same stylesheet to also break.

troysjanda commented 2 years ago

here is how Yahoo.com appears on FF 105.0.1 with Ubo 1.44.5b0 with deafult filters and my yahoocomplete list.

https://user-images.githubusercontent.com/24624945/192119567-98511124-1d22-4b46-bf41-f6b98040dba8.PNG

here is it under same browser with ubo 1.44.5b1

https://user-images.githubusercontent.com/24624945/192119620-dce8b591-5161-4ec2-b8dd-cf957bf619c3.PNG

troysjanda commented 2 years ago

I confirm fixed, and closing

Side Note: I was not trying to be difficult was just trying to give you all the information i could to help. Sorry if I was posting too much

krystian3w commented 2 years ago

On my side often cosmetic filters down on company page after open 2-3 categories with offering products.

Tested on Firefox 105.0.1 (No reproduce on Nightly 107) with uBo 1.44.5b9.

I don't open page in row or inactive tabs.

In logs I don't see any errors and crash add-on (with failed tries inject CSS to hide elements).

krystian3w commented 2 years ago

I have error but cut by "...": cosmetic-logger.js:88

SyntaxError: Document.querySelector: '.popmake[data-popmake*="cookie"],
.pum[data-popmake*="cookies-policy"],
.pum[data-popmake*="cookies-politique"],
.pum[data-popmake*="cookie-consent"],
.pum[data-popmake*="aviso-de-cookies"],
.pum[data-popmake*="cookies-datenschutz"],
.pum[data-popmake*=""slug":"cookie"],
.pum[data-popmake*="cookie-warning"],
.pum[data-popmake*="privacy"],
.pum[data-popmake*="gdpr"],
.pum[data-popmake*="pravila-privatnosti"],
.pum[data-popmake*="cookies-kakor"],
.pum[data-popmake*="cookie-policy"],
.widget.cookies,
.container[data-testid*="cookiePopup"],
.container[data-js*="cookie-message"],
.container.CookieConfirmation,
.container.cookies__base--open,
.container.UseCookie:not(body):not(html),
.row[data-test-selector*="cookie-banner"],
.row[class*="src-components-CookiePolicy"],
.row.allow-cookies:not(body):not(html),
#cookie-notice,
.cookie-notice-container,
.lightbox.cookie-optin-layer,
[class*="AdSlotPlaceholder"],
.slide-rss-out-div,
.google-news,
.google-news…
// line in file
        (node.querySelector(simpleDeclarativeStr) === null)

Possible guilty malform:

.pum[data-popmake*="\"slug\":\"cookie"] into: .pum[data-popmake*=""slug":"cookie"] (error with ").

to reporduce possible use page like: https://katowice.fonpizza.pl/kontakt/ with this setting list:

```yml uBlock Origin: 1.44.5b10 Firefox: 106 filterset (summary): network: 272293 cosmetic: 126250 scriptlet: 21728 html: 1057 listset (total-discarded, last-updated): added: https://gist.githubusercontent.com/krystian3w/587d9ba3e28a8e475d4782e44bd3d9b8/raw/remove.txt: 1000-0, 4d.17h.30m https://gist.githubusercontent.com/krystian3w/60817a0b8a3530e1ef1c5ba51246d6e2/raw/filters.txt: 157-1, 2d.13h.53m https://raw.githubusercontent.com/FiltersHeroes/KAD/master/KAD.txt: 174314-169, 2h.37m https://raw.githubusercontent.com/FiltersHeroes/PolishSocialCookiesFiltersDev/master/adblock_social_filters/adblock_social_list.txt: 13087-2, 6m https://raw.githubusercontent.com/PolishFiltersTeam/PolishAnnoyanceFilters/master/PPB.txt: 21925-9914, 6m https://raw.githubusercontent.com/PolishFiltersTeam/PolishAntiAnnoyingSpecialSupplement/master/polish_rss_filters.txt: 883-0, 4d.17h.30m https://raw.githubusercontent.com/PolishFiltersTeam/PolishSocialCookiesFiltersDev/master/cookies_filters/adblock_cookies.txt: 9595-17, 6m https://www.i-dont-care-about-cookies.eu/abp/: 25379-145, 1d.15h.55m adguard-spyware-url: 767-3, 2h.44m block-lan: 44-0, 4d.17h.31m fanboy-social: 23366-23, 3d.12m ublock-annoyances: 4861-6, 2h.39m default: user-filters: 194-0, never ublock-filters: 33766-88, 2h.47m ublock-badware: 4346-0, 2h.46m ublock-privacy: 273-0, 2h.41m ublock-abuse: 76-0, 2h.40m ublock-unbreak: 1877-1, 2h.45m ublock-quick-fixes: 258-0, 2h.33m easylist: 62266-636, 4d.17h.31m easyprivacy: 30639-1713, 4d.17h.31m urlhaus-1: 12383-0, 2h.33m plowe-0: 3670-3, 4d.17h.30m POL-0: 7855-30, 2h.33m POL-2: 1279-12, 2h.38m filterset (user): [array of 159 redacted] modifiedUserSettings: advancedUserEnabled: true cnameUncloakEnabled: false hyperlinkAuditingDisabled: false prefetchingDisabled: false webrtcIPAddressHidden: true modifiedHiddenSettings: autoCommentFilterTemplate: null extensionUpdateForceReload: true filterAuthorMode: true popupPanelLockedSections: 32 strictBlockingBypassDuration: 30 updateAssetBypassBrowserCache: true userResourcesLocation: [redacted] supportStats: allReadyAfter: 1376 ms maxAssetCacheWait: 735 ms ```

(Block something on page by cosmetic filter and fresh as element back to visible)

No help purge all cache.

krystian3w commented 2 years ago

Definitely these filters break cosmetic filtering on pizza page and company shop:

##.foo[bar*="\"one\":\"two"]

##.foo[bar*='"one":"two']

But on Firefox 105 no warn SyntaxError. It may help disable all filters with " as value for attributes by #@#.foo....

Interest is fact breakage no longer exists with Firefox 107 (big changes in JavaScript API?).

gorhill commented 2 years ago

Thanks for narrowing this down, it's probably behind vague cases of things not working properly.

krystian3w commented 2 years ago

Hi,

Now will be broken use :nth-child(odd) and/or :nth-child(even) — malformed into empty :nth-child().

Still helps use #@# — cosmetic filtering back to work.

gorhill commented 2 years ago

By the way I use this tool to investigate what the csstree parser generates as a result of parsing a selector: https://astexplorer.net/#/gist/244e2fb4da940df52bf0f4b94277db44/e79aff44611020b22cfd9708f3a99ce09b7d67a8. Paste a selector with {} to ensure the tool works properly. The result of the parsing is under prelude property.

krystian3w commented 2 years ago

For me the tool is not readable so I hunted for several hours for a readable SyntaxError.

gorhill commented 2 years ago

What do you mean "not readable"?

troysjanda commented 2 years ago

What do you mean "not readable"?

Could you proved an example on how to use https://astexplorer.net/#/gist/244e2fb4da940df52bf0f4b94277db44/e79aff44611020b22cfd9708f3a99ce09b7d67a8 not sure I am using it correctly

gorhill commented 2 years ago

Well using the recent issue, paste this in the editor:

:nth-child(odd)
{}

The first line is the CSS selector to parse, the second is just an empty block the tool expects (normally filled with style properties.

If a valid CSS selector is used, the parser will fill the prelude property with the details of the parsing. If an invalid CSS selector is used, let's say :nth-child(od), the parser will end up using Raw entries.

However, the nice thing with the csstree parser is that it will parse uBO pseudo-operators as pseudo-classes, thus providing free parsing for these:

:has-text(...)
{}

The only "issue" which is the actual debt incurred in uBO is that I never requested that the arguments to pseudo-operators be properly quoted or escaped (except for parentheses), and sometimes this trips the parser:

:has-text(')
{}
:has-text(")
{}

Some characters have special meaning in CSS, and the single quote above trips the parser. Solution, use quotes:

:has-text("'")
{}
:has-text('"')
{}

uBO will remove the quotes in such case before using the argument.

Currently the cosmetic filters found as invalid because of the special characters can be seen in https://github.com/gorhill/uBlock/blob/master/dist/mv3/log.txt, search for Invalid filter:. There are not that many of them considering all the cosmetic filters being processed, and these will be rejected at compile time, and we can fix them through reports or just remove them if they are found to be obsolete.

troysjanda commented 2 years ago

Thank you Now I understand. Much appreciated.

troysjanda commented 2 years ago

Well using the recent issue, paste this in the editor:

:nth-child(odd)
{}

The first line is the CSS selector to parse, the second is just an empty block the tool expects (normally filled with style properties.

If a valid CSS selector is used, the parser will fill the prelude property with the details of the parsing. If an invalid CSS selector is used, let's say :nth-child(od), the parser will end up using Raw entries.

However, the nice thing with the csstree parser is that it will parse uBO pseudo-operators as pseudo-classes, thus providing free parsing for these:

:has-text(...)
{}

The only "issue" which is the actual debt incurred in uBO is that I never requested that the arguments to pseudo-operators be properly quoted or escaped (except for parentheses), and sometimes this trips the parser:

:has-text(')
{}
:has-text(")
{}

Some characters have special meaning in CSS, and the single quote above trips the parser. Solution, use quotes:

:has-text("'")
{}
:has-text('"')
{}

uBO will remove the quotes in such case before using the argument.

Currently the cosmetic filters found as invalid because of the special characters can be seen in https://github.com/gorhill/uBlock/blob/master/dist/mv3/log.txt, search for Invalid filter:. There are not that many of them considering all the cosmetic filters being processed, and these will be rejected at compile time, and we can fix them through reports or just remove them if they are found to be obsolete.

Is there a script that I could run on my lists to see if there are invalid cosmetic filters, just curious if that can be done. Also is there a way Ubo can auto correct those , or does that create too much overhead. reason i ask, as being a beginner filter creator I use picker to make the majority of my filters and this would be handy tool to parse my lists to see if I have CSSTree type invalid filters. hope that makes since.

krystian3w commented 2 years ago

If script show malfromation of nth-, attributes [a="\""] then maybe worth rewrite to webpage like:

https://www.reddragonwebdesign.com/projects/adblock-filter-analyzer/

These is important due can disable hide ads on YouTube and Reddit.

krystian3w commented 2 years ago

https://astexplorer.net/#/gist/244e2fb4da940df52bf0f4b94277db44/8d78949ba0fc0410b017316318105b3ebd4c7cd9 - many unknown but ad end detect "nth-".

These now works similar to ##*.

But rare chance of exist filter in list with support Safari 9 - 16 e.g. by AdGuard environment.