Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/subscriptions/bin/updateMalwareDomainsList.py

Issue 29333567: Issue 3521 - Worked around Malware Domains List breaking YouTube (Closed)
Patch Set: Created Jan. 15, 2016, 11:30 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 22 matching lines...) Expand all
33 ! This is a list of malware domains generated from malwaredomains.com data. 33 ! This is a list of malware domains generated from malwaredomains.com data.
34 ! Homepage: http://malwaredomains.com/?page_id=2 34 ! Homepage: http://malwaredomains.com/?page_id=2
35 ! Last modified: %timestamp% 35 ! Last modified: %timestamp%
36 ! Expires: 1d 36 ! Expires: 1d
37 !''' 37 !'''
38 38
39 data = urllib.urlopen('http://mirror3.malwaredomains.com/files/justdomains.z ip').read() 39 data = urllib.urlopen('http://mirror3.malwaredomains.com/files/justdomains.z ip').read()
40 zip = zipfile.ZipFile(StringIO(data), 'r') 40 zip = zipfile.ZipFile(StringIO(data), 'r')
41 info = zip.infolist()[0] 41 info = zip.infolist()[0]
42 for line in str(zip.read(info.filename)).splitlines(): 42 for line in str(zip.read(info.filename)).splitlines():
43 if not line: 43 domain = line.strip()
44 if not domain:
44 continue 45 continue
45 print >>file, '||%s^' % line.strip().decode('idna') 46
47 # HACK: Ignore entry that currently breaks YouTube, see #3521
48 if domain == 's.ytimg.com':
49 continue
50
51 print >>file, '||%s^' % domain.decode('idna')
46 file.close(); 52 file.close();
47 53
48 if subprocess.check_output(['hg', 'stat', '-R', tempdir]) != '': 54 if subprocess.check_output(['hg', 'stat', '-R', tempdir]) != '':
49 subprocess.check_call(['hg', '-q', 'commit', '-R', tempdir, '-A', '-u', 'h gbot', '-m', 'Updated malwaredomains.com data']) 55 subprocess.check_call(['hg', '-q', 'commit', '-R', tempdir, '-A', '-u', 'h gbot', '-m', 'Updated malwaredomains.com data'])
50 subprocess.check_call(['hg', '-q', 'push', '-R', tempdir]) 56 subprocess.check_call(['hg', '-q', 'push', '-R', tempdir])
51 finally: 57 finally:
52 shutil.rmtree(tempdir, ignore_errors=True) 58 shutil.rmtree(tempdir, ignore_errors=True)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld