Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#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):

https://codereview.adblockplus.org/30053555/

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": [
          ...
       ]
     }, 
     ...
  ]
}

Change History (6)

comment:1 Changed 7 months ago by kvas

  • Description modified (diff)
  • Summary changed from [python-abp] Variables inside filter list comments to [python-abp] Parsing filter blocks

I updated the ticket based on further discussion with Edmundo and clarified use case.

comment:2 Changed 7 months ago by esanchez

  • Cc esanchez added

comment:3 Changed 7 months ago by kvas

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:4 Changed 7 months ago by abpbot

A commit referencing this issue has landed:
Issue 7471 - Add an API for working with blocks of filters

comment:5 Changed 7 months ago by kvas

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:6 Changed 7 months ago by greiner

  • Cc greiner added
Note: See TracTickets for help on using tickets.