brave/adblock-rust

$redirect rules from brave-unbreak list not working as they should

Closed this issue · 4 comments

Hi
Just like @antonok-edm this fix you did today, many other rules are having similar problems.

The thing is the same exactly rules in brave-unbreak work as custom filters

  • Best way I can show you this issue? :
    Go to zillow.com open Devtools and check how only beacon.js is he only getting the redirected with the uBlock Origin script text on it.
    analytics.js and gtm.js don't appear in the list of sources and they are only getting blocked, not redirected.

Now add to the custom filters box (which are the exact same rules in brave-unbreak):

||googletagmanager.com/gtm.js$script,redirect=googletagmanager_gtm.js
||google-analytics.com/analytics.js$script,redirect=google-analytics.com/analytics.js

Refresh zillow, now the analytics and the gtm should have the script with uBlock Origin text on it because they got redirected.

Of course in this case it doesn't affect much if they are blocked or redirected, but in some pages this issue cause trouble in the pages, breaking it like happens in National Review where you can test how it will show a message because googletagservices.com/gpt.js redirection is not being applied and gpt is only being blocked.

if you add ||googletagservices.com/tag/js/gpt.js$script,redirect=googletagservices.com/gpt.js as a custom filter, it doesn't display that '_ googletag, is not a function_'.

In other pages the adblocker will be detected for blocking and not redirecting, which obviously means users unhappy and thinking uBlock is better, and users having to turn their shields off because of this, which means their protections will be limited.
I made my own fixes, and even added $important property in my custom rules because some rules in brave-unbreak whitelisted the JS with @@||, so I wanted to override all that made by Brave team because apparently you never saw this weird issue.

Note: I run uBlock side by side with Brave's adblocker, that's how I noticed it, because of the national review page. Now I compare the lists and behaviors running uBlock, if a website detects the adblocker or something seems to break it or if I see some element being blocked in uBlock that Brave is not blocking I troubleshoot to see why, until I can turn off uBlock and Brave will behave the same and I can run Brave without uBlock next to it.

Thank you.

I just tested adding https://raw.githubusercontent.com/brave/adblock-lists/master/brave-unbreak.txt as a custom list just to see what happened, testing the new adblock-rust 0.5.8 (yes, I am using Nightly 1.47.9), and it works, the scripts are getting redirected just as they should.

So it seems they work as custom list but not as default. And this way is even easier to test, turn off the list and it shows the problem of not redirecting the scripts correctly, turn on the list and it works just as they should.

Perhaps @ryanbr could take a look at those specific examples, but sadly I don't think this will be possible to address until proper support for redirect priority is implemented.

Since we're already tracking that in #222, I'll close this.

@antonok-edm
In a way your response makes sense because supporting priority will be the best thing, to really manage redirect rules, that would be the easiest thing to deal with.

But the problem is the rules without the priority were added to Brave-unbreak, but they are ignored, I didn't see anything in the unbreak list that could explain that, unless Easylist are taking higher priority and then just blocking the elements and ignoring the redirect, but then, if that was the case, why beacon.js gets redirected and not the others like analytics and gtm, and gpt and adsbygoogle? beacon.js rule in uBlock also has a priority integer, so if this theory was real, then that would also fail.

When the rules work when you add brave-unbreak as custom list but not as default, that's the confusing part.

Are custom filters now taking higher priority than default lists?

That still wouldn't explain why the filters are getting ignored, but it could explain something. But not all because as far as I know, when a rule has an unsupported feature like $popup, shouldn't the adblocker completely ignore it anyway? which means the ones with priority would get ignored and use the ones without priority in brave-unbreak?

I already fixed this issue myself with my own custom list for redirect filters, so I am not like really caring too much if this exists or not, but these are the questions why I opened this issue because helped other people having trouble because of this.
But I guess I will keep suggesting people to add the redirect rules as custom filters until priority gets supported and then the rules can be removed from brave-unbreak, they are not going to die for copying and pasting some rules.

Thank you! and thanks for your work.

@antonok-edm I wanted to update this because I finally found why the rules are being ignored.
I was doing some tests so I found a way to turn Default off completely myself to load the Default lists as custom lists.
I did that by completely blocking the folder where list.txt is downloaded, which let me test things better and see what is going on with Brave.

You are 100% right, the issue can only be solved when Brave supports the priority feature, but it is not because of the lack of the feature in Brave, but because of the way Brave gets the filter lists! that's the reason the lack of the feature matters in this case.
Since the lists get merged in the list.txt file and all the rules exist in the same file, for whatever reason Brave adblocker is only trying to use the $redirect with :5 and doesn't try to use the one without priority.

It happens even if you make a custom list with these two rules or add them as custom filters.

||analytics.brave.com/matomo.js$script,redirect=noopjs
||analytics.brave.com/matomo.js$script,redirect=noopjs:5

Devtools will show the script was only blocked and not redirected.

So the list.txt having all the rules in the same file will cause the problem regardless of anything.

In other words, the $redirect rules that were added to Brave-unbreak list are completely useless because changing resources or using alias like noop.js or using $important won't work at all, Brave will use the one that doesn't work that has the priority.

The only way it would work since the priority is not supported, it's if both rules are in different files, which means splitting the list.txt in different files like I loaded all Default lists as custom lists (not going to happen ever or anytime soon).

Or changing the rules from $redirect to $redirect-rule, in Brave-unbreak, since they will do the same in this case, but since they are different rules then they won't conflict with uBlock filter list.
Of course, I will guess, this depends on @ryanbr more than you. But since redirect-rule will be added eventually to Stable, I thought that at least the rules will work in the future, instead of being there in the list doing nothing until the priority is supported.

Anyway sorry! that's all I wanted to say and now I can finally rest in peace and leave this issue behind.

Have a good day!