Opened on 05/08/2019 at 12:09:29 PM
Closed on 05/10/2019 at 08:33:52 AM
Last modified on 05/14/2019 at 05:16:35 PM
#7471 closed change (fixed)
[python-abp] Parsing filter blocks
Reported by: | kvas | Assignee: | |
---|---|---|---|
Priority: | P3 | Milestone: | |
Module: | Sitescripts | Keywords: | |
Cc: | esanchez, greiner | Blocked By: | |
Blocking: | Platform: | Unknown / Cross platform | |
Ready: | yes | Confidential: | no |
Tester: | Unknown | Verified working: | no |
Review URL(s): |
Description (last modified by kvas)
Background
Our exception list contains blocks like this:
!:partner_token=heise.de !:partner_id=ee1f510910c7063c !:type=partner !:forum=https://adblockplus.org/forum/viewtopic.php?f=12&t=9803 ! Text/image ads on heise.de @@||g.doubleclick.net/pcs/view?$image,domain=heise.de @@||googlesyndication.com/simgad/$image,domain=heise.de @@||g.doubleclick.net/gampad/ads?*%2Cabp&$script,xmlhttprequest,domain=heise.de @@||heise.de/js/prebid*.js$domain=heise.de heise.de#@#.ad-container heise.de#@#iframe[id^="google_ads_iframe"] heise.de#@#div[id^="google_ads_iframe_"] heise.de##a-ad:not([acceptable])
There are several contexts, in which we would like to work with these blocks directly (one of these is Edmundo's work on a streamlined whitelisting process that lead to the original formulation of this ticket). It would be good if python-abp could provide a standardized and convenient way to work with such blocks.
What to change
Provide an API that takes a sequence of parsed filters (and other filter list lines) and returns a sequence of FiltersBlock objects that contain the properties defined via !:<name>=<value> syntax as well as filters that is a list of filter objects and description, which is all normal comments (separated by line breaks).
Filter blocks should also support _asdict() API that converts them to nested Python dicts for further JSON-ization (filters already support it by virtue of being named tuples). Example:
{ “partner_token”: “heise.de”, “partner_id”: ”ee1f510910c7063c”, “type”: "partner", “forum”: ”https://adblockplus.org/forum/viewtopic.php?f=12&t=9803”, “description”: ”Text/image ads on heise.de” “filters”: [ { "text": "@@||g.doubleclick.net/pcs/view?$image,domain=heise.de", "selector": { "type": "url-pattern", "value": "||g.doubleclick.net/pcs/view?" }, "action": "allow", "options": [ ... ] }, ... ] }
Attachments (0)
Change History (6)
comment:1 Changed on 05/08/2019 at 03:26:28 PM by kvas
- Description modified (diff)
- Summary changed from [python-abp] Variables inside filter list comments to [python-abp] Parsing filter blocks
comment:2 Changed on 05/08/2019 at 07:23:08 PM by esanchez
- Cc esanchez added
comment:3 Changed on 05/09/2019 at 11:19:22 AM by kvas
- Review URL(s) modified (diff)
- Status changed from new to reviewing
comment:4 Changed on 05/10/2019 at 08:33:31 AM by abpbot
A commit referencing this issue has landed:
Issue 7471 - Add an API for working with blocks of filters
comment:5 Changed on 05/10/2019 at 08:33:52 AM by kvas
- Resolution set to fixed
- Status changed from reviewing to closed
comment:6 Changed on 05/14/2019 at 05:16:35 PM by greiner
- Cc greiner added
I updated the ticket based on further discussion with Edmundo and clarified use case.