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