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

Unified Diff: abp/filters/parser.py

Issue 29879650: Issue 6950 - Don't include headers and metadata from includes into output (Closed)
Patch Set: Test for "Last modified" Created Sept. 14, 2018, 3:32 p.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 | abp/filters/renderer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: abp/filters/parser.py
===================================================================
--- a/abp/filters/parser.py
+++ b/abp/filters/parser.py
@@ -140,7 +140,7 @@
Include = _line_type('Include', 'target', '%include {0.target}%')
-METADATA_REGEXP = re.compile(r'([\w-]+)\s*:\s*(.*)')
+METADATA_REGEXP = re.compile(r'(.*?)\s*:\s*(.*)')
INCLUDE_REGEXP = re.compile(r'%include\s+(.+)%')
HEADER_REGEXP = re.compile(r'\[(Adblock(?:\s*Plus\s*[\d\.]+?)?)\]', flags=re.I)
HIDING_FILTER_REGEXP = re.compile(r'^([^/*|@"!]*?)#([@?])?#(.+)$')
@@ -319,7 +319,7 @@
for line in lines:
result = parse_line(line)
- if isinstance(result, Comment):
+ if result.type == 'comment':
match = METADATA_REGEXP.match(result.text)
if match:
key, value = match.groups()
@@ -330,12 +330,9 @@
# we have to make sure to still parse them regardless of
# their position in the filter list.
if not metadata_closed or key.lower() == 'checksum':
- yield Metadata(key, value)
- continue
+ result = Metadata(key, value)
- if not result.text:
- metadata_closed = True
- elif not isinstance(result, Header):
+ if result.type not in {'header', 'metadata'}:
metadata_closed = True
yield result
« no previous file with comments | « no previous file | abp/filters/renderer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld