Skip to content

Loading…

Dynamic Filtering: Can't use noop or allow rule for image type based on destination-hostname #840

Closed
WalterWW opened this Issue · 6 comments

2 participants

@WalterWW

I was trying to add the following rule in order to allow all webpages to load images (and only images) from imgur.com:

* imgur.com image noop

Unfortunately that doesn't work. I tried the same using 'allow' instead of 'noop', to no avail.
Adding a source-hostname didn't help either, so the wildcard for the source doesn't seem to be the problem.

Platform: Debian / Iceweasel

@gorhill

By design. There is no UI to do this. Anything more than what is there will have to be another extension: Policeman.

@gorhill gorhill closed this
@WalterWW

Okay. I just somehow expected this to work fron reading the rules-syntax description in the wiki.

Thank you for the quick reply.

@gorhill

Note that with type-based rules, the destination hostname is always *, meaning "from anywhere".
With hostname-based rule, the type is always *, meaning the rule will apply to any type of request.

@WalterWW

Makes sense.

Maybe the parser for the rules could check for this condition and visibly invalidate or reject the rule if the condition is not true?

Probably very low priority, but just an idea to prevent any confusion of this kind in the future.

@gorhill

could check for this condition and invalidate the rule if the condition is not true?

Ok, will do, as it does this already for other unparseable lines.

@gorhill gorhill reopened this
@WalterWW

Glad to hear that. I have to say I spent quite a bit of time trying to figure out why it isn't working and if I did something wrong, until finally giving up and coming here with this thread. Rejecting invalid rules like that could probably save other people a lot of time.

I also understand that you're striving for efficiency and simplicity with ublock, and I can absolutely respect that. You're right that if I wanted to have more granular control over the differnt kind of requests that should go through or get filtered, I could use something like Policeman. I actually played around with Policeman before and I liked it quite a lot, but I feel it would be too redundant to use alongside ublock now that ublock has dynamic filtering capabilities.

So I figured out a way to achieve what I was trying to do within ublock after all:

Using a default-deny or deny-3rd-party setup, it's possible to allow all sites to load images and only images from imgur.com by doing the following (maybe someone reading this might be interested in this solution):

First create a noop rule to allow requests to imgur.com for all sites:

* imgur.com * noop

Then create a filter rule to block everything from imgur.com except images:

||imgur.com^$third-party,~image

I can definitely live with that solution as this scenario isn't really all that common for me, so it's not enough to justify installing a redundant addon such as policeman for the additional funcionality.

All in all, great job with ublock! I have been using Requestpolicy in combination with ABE for ages now, and have now replaced those two addons with a single, better one. Thanks :)

@gorhill gorhill added a commit that closed this issue
@gorhill gorhill this fixes #840 f65d44b
@gorhill gorhill closed this in f65d44b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.