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

Side by Side Diff: abp/filters/rpy.py

Issue 29880577: Issue 6877 - Only parse headers in the first line of the filter list (Closed)
Patch Set: Initial Created Sept. 14, 2018, 4:43 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if isinstance(data, list): 65 if isinstance(data, list):
66 return [strings2utf8(v) for v in data] 66 return [strings2utf8(v) for v in data]
67 if isinstance(data, tuple): 67 if isinstance(data, tuple):
68 return tuple(strings2utf8(v) for v in data) 68 return tuple(strings2utf8(v) for v in data)
69 if isinstance(data, type('')): # Python 2/3 compatible way of 69 if isinstance(data, type('')): # Python 2/3 compatible way of
70 # saying "unicode string". 70 # saying "unicode string".
71 return data.encode('utf-8') 71 return data.encode('utf-8')
72 return data 72 return data
73 73
74 74
75 def line2dict(text): 75 def line2dict(text, mode='body'):
76 """Convert a filterlist line to a dictionary. 76 """Convert a filterlist line to a dictionary.
77 77
78 All strings in the output dictionary will be UTF8 byte strings. This is 78 All strings in the output dictionary will be UTF8 byte strings. This is
79 necessary to prevent unicode encoding errors in rPython conversion layer. 79 necessary to prevent unicode encoding errors in rPython conversion layer.
80 80
81 Parameters 81 Parameters
82 ---------- 82 ----------
83 text: str 83 text: str
84 The filter text we want to parse 84 The filter text we want to parse
85 mode: str
86 Parsing mode (see `abp.filters.parser.parse_line`).
85 87
86 Returns 88 Returns
87 ------- 89 -------
88 dict 90 dict
89 With the parsing results and all strings converted to utf8 byte 91 With the parsing results and all strings converted to utf8 byte
90 strings. 92 strings.
91 93
92 """ 94 """
93 return strings2utf8(tuple2dict(parse_line(text))) 95 return strings2utf8(tuple2dict(parse_line(text, mode)))
OLDNEW
« abp/filters/parser.py ('K') | « abp/filters/parser.py ('k') | tests/test_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld