From: joerg Date: Thu, 11 Oct 2012 06:53:26 +0000 (+0000) Subject: Add patch from Paul Wise to filter out various unwanted stuff X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=b7651f7d143e1d964a386ac3c1aeb6ae0544882e;p=deb%2Fhackedgotchi.git Add patch from Paul Wise to filter out various unwanted stuff git-svn-id: svn+ssh://svn.debian.org/svn/planet-debian/trunk@1618 c2f067bf-98e0-425f-9c98-e76020cfa380 --- diff --git a/config/config.ini b/config/config.ini index 08d4ea6..35f1d16 100644 --- a/config/config.ini +++ b/config/config.ini @@ -61,6 +61,9 @@ days_per_page = 0 encoding = utf-8 # locale = C +filters = remove-trackers-and-ads.plugin +filter_directories = filters = remove-trackers-and-ads.plugin + [templates/index.html.tmpl] date_format = %I:%M%P diff --git a/config/config.ini.deriv b/config/config.ini.deriv index a6a5c30..d4da95a 100644 --- a/config/config.ini.deriv +++ b/config/config.ini.deriv @@ -93,6 +93,9 @@ days_per_page = 0 encoding = utf-8 # locale = C +filters = remove-trackers-and-ads.plugin +filter_dir = filters + [templates/index.html.dj] date_format = %I:%M%P diff --git a/config/config.ini.es b/config/config.ini.es index 5e18ace..0642059 100644 --- a/config/config.ini.es +++ b/config/config.ini.es @@ -92,6 +92,9 @@ days_per_page = 0 encoding = utf-8 # locale = C +filters = remove-trackers-and-ads.plugin +filter_dir = filters + [templates/index.html.dj] date_format = %I:%M%P diff --git a/config/config.ini.tmpl b/config/config.ini.tmpl index c28e7a6..0cb1924 100644 --- a/config/config.ini.tmpl +++ b/config/config.ini.tmpl @@ -93,6 +93,9 @@ days_per_page = 0 encoding = utf-8 # locale = C +filters = remove-trackers-and-ads.plugin +filter_dir = filters + [templates/index.html.dj] date_format = %I:%M%P diff --git a/filters/remove-trackers-and-ads.plugin b/filters/remove-trackers-and-ads.plugin new file mode 100644 index 0000000..84c2a04 --- /dev/null +++ b/filters/remove-trackers-and-ads.plugin @@ -0,0 +1,26 @@ +import sys +import re + +data = sys.stdin.read() + +regexes = [ + # Blogger tracking images + r"""]*?src=["']https?://blogger\.googleusercontent\.com/tracker/[^'"]*['"][^>]*>""", + # Feedburner ads + r"""

""", + # Feedburner tracking images + r"""]*?src=['"]https?://feeds\.feedburner\.com/~r/[^"']*['"][^>]*>""", + # Wordpress tracking images + r"""]*?src=['"]https?://stats\.wordpress\.com/b\.gif[^"']*['"][^>]*>""", + # Amazon tracking images + r"""]*?src=['"]https?://www\.assoc-amazon\.com/e/ir[^"']*['"][^>]*>""", + # Paypal tracking images + r"""]*?src=['"]https?://www\.paypalobjects\.com/[^/]*/i/scr/pixel.gif[^"']*['"][^>]*>""", + # Other tracking images + r']*?width=["']1["'][^>]*?height=["']1["'][^>]*>', + r']*?height=["']1["'][^>]*?width=["']1["'][^>]*>', +] + +for regex in regexes: data = re.sub(regex, '', data) + +sys.stdout.write(data)