scrapinghub / adblockparser

Python parser for Adblock Plus filters
MIT License
194 stars 29 forks source link

Invalid rule easyprivacy.txt + better errors #12

Open Northshoot opened 6 years ago

Northshoot commented 6 years ago

Hey,

I am getting error then using https://easylist.to/easylist/easyprivacy.txt Would be great to get the rule that is erroneous in the error message.

with open('easyprivacy.txt', 'rb') as f: content = f.read().decode('utf8').splitlines() rules = AdblockRules(content)

Error

File "/usr/local/lib/python3.6/site-packages/adblockparser/parser.py", line 306, in __init__ for r in rules File "/usr/local/lib/python3.6/site-packages/adblockparser/parser.py", line 304, in <listcomp> r for r in ( File "/usr/local/lib/python3.6/site-packages/adblockparser/parser.py", line 306, in <genexpr> for r in rules File "/usr/local/lib/python3.6/site-packages/adblockparser/parser.py", line 117, in __init__ self.regex = self.rule_to_regex(rule_text) File "/usr/local/lib/python3.6/site-packages/adblockparser/parser.py", line 233, in rule_to_regex raise AdblockParsingError('Invalid rule') adblockparser.parser.AdblockParsingError: Invalid rule

pgirolami commented 6 years ago

Same here, I've found it is due to this rule

/$file/analytics.

added 16 days ago.

I can't see anything in the Adblock filter rules to explain $file though

gonedjur commented 6 years ago

I can't get any of the easylists to work at all?

>>> with open('fanboy_social_general_block.txt', 'rb') as f:
...     raw_rules = f.read().decode('utf8').splitlines()
>>> rules = AdblockRules(raw_rules)
>>> rules.should_block("http://www.facebook.com")
False
>>> with open('easylist.txt', 'rb') as f:
...     raw_rules = f.read().decode('utf8').splitlines()
>>> rules = AdblockRules(raw_rules)
>>> rules.should_block("http://ads.example.com")
False

Any ideas? Are they no longer compatible?