| Index: abp/filters/parser.py |
| =================================================================== |
| --- a/abp/filters/parser.py |
| +++ b/abp/filters/parser.py |
| @@ -137,18 +137,17 @@ |
| Comment = _line_type('Comment', 'text', '! {.text}') |
| Metadata = _line_type('Metadata', 'key value', '! {0.key}: {0.value}') |
| Filter = _line_type('Filter', 'text selector action options', '{.text}') |
| Include = _line_type('Include', 'target', '%include {0.target}%') |
| METADATA_REGEXP = re.compile(r'\s*!\s*(.*?)\s*:\s*(.*)') |
| INCLUDE_REGEXP = re.compile(r'%include\s+(.+)%') |
| -HEADER_REGEXP = re.compile(r'\[(?:(Adblock(?:\s*Plus\s*[\d\.]+?)?)|.*)\]', |
| - flags=re.I) |
| +HEADER_REGEXP = re.compile(r'\[(Adblock(?:\s*Plus\s*[\d\.]+?)?)\]', flags=re.I) |
| HIDING_FILTER_REGEXP = re.compile(r'^([^/*|@"!]*?)#([@?])?#(.+)$') |
| FILTER_OPTIONS_REGEXP = re.compile( |
| r'\$(~?[\w-]+(?:=[^,]+)?(?:,~?[\w-]+(?:=[^,]+)?)*)$' |
| ) |
| def _parse_instruction(text): |
| match = INCLUDE_REGEXP.match(text) |
| @@ -289,20 +288,17 @@ |
| stripped = line.strip() |
| if stripped == '': |
| return EmptyLine() |
| if position == 'start': |
| match = HEADER_REGEXP.search(line) |
| if match: |
| - version = match.group(1) |
| - if not version: |
| - raise ParseError('Malformed header', line) |
| - return Header(version) |
| + return Header(match.group(1)) |
| if stripped.startswith('!'): |
| match = METADATA_REGEXP.match(line) |
| if match: |
| key, value = match.groups() |
| if position != 'body' or key.lower() == 'checksum': |
| return Metadata(key, value) |
| return Comment(stripped[1:].lstrip()) |