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

Unified Diff: sitescripts/subscriptions/combineSubscriptions.py

Issue 6282217760227328: Issue 199 - [filter lists] Don`t allow multiple Expires comments (Closed)
Patch Set: Created March 24, 2014, 7:52 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/subscriptions/combineSubscriptions.py
===================================================================
--- a/sitescripts/subscriptions/combineSubscriptions.py
+++ b/sitescripts/subscriptions/combineSubscriptions.py
@@ -84,17 +84,17 @@ def process_subscription_file(source_nam
if not re.search(r"\[Adblock(?:\s*Plus\s*([\d\.]+)?)?\]", header, re.I):
raise Exception("This is not a valid Adblock Plus subscription file.")
lines = resolve_includes(source_name, sources, lines, timeout)
seen = set(["checksum", "version"])
def check_line(line):
if line == "":
return False
- match = re.search(r"^\s*!\s*(Redirect|Homepage|Title|Checksum|Version)\s*:", line, re.M | re.I)
+ match = re.search(r"^\s*!\s*(Redirect|Homepage|Title|Checksum|Version|Expires)\s*:", line, re.M | re.I)
if not match:
return True
key = match.group(1).lower()
if key in seen:
return False
seen.add(key)
return True
lines = filter(check_line, lines)
@@ -133,18 +133,17 @@ def resolve_includes(source_name, source
time.sleep(5)
if error:
raise error
# We should really get the charset from the headers rather than assuming
# that it is UTF-8. However, some of the Google Code mirrors are
# misconfigured and will return ISO-8859-1 as charset instead of UTF-8.
newlines = data.decode("utf-8").splitlines()
- newlines = filter(lambda l: not re.search(r"^\s*!.*?\bExpires\s*(?::|after)\s*(\d+)\s*(h)?", l, re.M | re.I), newlines)
- newlines = filter(lambda l: not re.search(r"^\s*!\s*(Redirect|Homepage|Title|Version)\s*:", l, re.M | re.I), newlines)
+ newlines = filter(lambda l: not re.search(r"^\s*!\s*(Redirect|Homepage|Title|Version|Expires)\s*:", l, re.M | re.I), newlines)
else:
result.append("! *** %s ***" % filename)
include_source = source_name
if ":" in filename:
include_source, filename = filename.split(":", 1)
if not include_source in sources:
raise Exception('Cannot include file from repository "%s", this repository is unknown' % include_source)
@@ -166,17 +165,17 @@ def resolve_includes(source_name, source
return result
def write_tpl(save_file, filename, lines):
result = []
result.append("msFilterList")
for line in lines:
if re.search(r"^\s*!", line):
# This is a comment. Handle "Expires" comment in a special way, keep the rest.
- match = re.search(r"\bExpires\s*(?::|after)\s*(\d+)\s*(h)?", line, re.I)
+ match = re.search(r"^\s*!\s*Expires\s*:\s*(\d+)\s*(h)?", line, re.I)
if match:
interval = int(match.group(1))
if match.group(2):
interval = int(interval / 24)
result.append(": Expires=%i" % interval)
else:
result.append(re.sub(r"^\s*!", "#", re.sub(r"--!$", "--#", line)))
elif line.find("#") >= 0:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld