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

Delta Between Two Patch Sets: abp/filters/parser.py

Issue 29793573: Issue 6701 - Implement CSP support in python-abp (Closed) Base URL: https://hg.adblockplus.org/python-abp/
Left Patch Set: Condense the tests, properly handle ~csp Created June 12, 2018, 9:09 p.m.
Right Patch Set: Removing handling and testing for ~csp Created June 14, 2018, 7:48 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « .hgignore ('k') | tests/test_parser.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 166
167 def _parse_instruction(text): 167 def _parse_instruction(text):
168 match = INCLUDE_REGEXP.match(text) 168 match = INCLUDE_REGEXP.match(text)
169 if not match: 169 if not match:
170 raise ParseError('Unrecognized instruction', text) 170 raise ParseError('Unrecognized instruction', text)
171 return Include(match.group(1)) 171 return Include(match.group(1))
172 172
173 173
174 def _parse_option(option): 174 def _parse_option(option):
175 if option.startswith('~csp'):
176 return 'csp', False
177 if '=' in option: 175 if '=' in option:
178 return option.split('=', 1) 176 return option.split('=', 1)
179 if option.startswith('~'): 177 if option.startswith('~'):
180 return option[1:], False 178 return option[1:], False
181 return option, True 179 return option, True
182 180
183 181
184 def _parse_filter_option(option): 182 def _parse_filter_option(option):
185 name, value = _parse_option(option) 183 name, value = _parse_option(option)
186 184
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 Raises 313 Raises
316 ------ 314 ------
317 ParseError 315 ParseError
318 Thrown during iteration for invalid filter list lines. 316 Thrown during iteration for invalid filter list lines.
319 TypeError 317 TypeError
320 If `lines` is not iterable. 318 If `lines` is not iterable.
321 319
322 """ 320 """
323 for line in lines: 321 for line in lines:
324 yield parse_line(line) 322 yield parse_line(line)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld