-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
The regex at
adblockparser/adblockparser/parser.py
Line 264 in 4089612
| rule = r"^(?:[^:/?#]+:)?(?://(?:[^/?#]*\.)?)?" + rule[2:] |
You might want to block http://example.com/banner.gif as well as https://example.com/banner.gif and http://www.example.com/banner.gif. You can do this by putting two pipe symbols in front of the filter. This ensures that the filter matches at the beginning of the domain name: ||example.com/banner.gif, and blocks all of these addresses while not blocking http://badexample.com/banner.gif or http://gooddomain.example/analyze?http://example.com/banner.gif.
If I understand this correctly, it should also block wss:www.example.com/banner.gif but in this implementation, it doesn't.
>>> from adblockparser import AdblockRules
>>> rules = AdblockRules(['||example.com/banner.gif'])
>>> rules.should_block('http://example.com/banner.gif')
True
>>> rules.should_block('http://www.example.com/banner.gif')
True
>>> rules.should_block('wss:example.com/banner.gif')
True
>>> rules.should_block('wss:www.example.com/banner.gif')
False(should be True)
Metadata
Metadata
Assignees
Labels
No labels