Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
4 # Copyright (C) 2006-2015 Eyeo GmbH | 4 # Copyright (C) 2006-2015 Eyeo GmbH |
5 # | 5 # |
6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify |
7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as |
8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
9 # | 9 # |
10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 default, saved_attributes, fixed_strings = self._attribute_parser.parse(defa ult, self._params["page"]) | 132 default, saved_attributes, fixed_strings = self._attribute_parser.parse(defa ult, self._params["page"]) |
133 | 133 |
134 # Get translation | 134 # Get translation |
135 if self._params["locale"] != self._params["defaultlocale"] and name in local edata: | 135 if self._params["locale"] != self._params["defaultlocale"] and name in local edata: |
136 result = localedata[name].strip() | 136 result = localedata[name].strip() |
137 else: | 137 else: |
138 result = default | 138 result = default |
139 | 139 |
140 # Insert fixed strings | 140 # Insert fixed strings |
141 for i in range(len(fixed_strings)): | 141 for i in range(len(fixed_strings)): |
142 result = re.sub(re_escape("{%d}" % (i + 1)), fixed_strings[i], result, 1) | 142 result = re.sub(r"\{%d\}" % (i + 1), fixed_strings[i], result, 1) |
Wladimir Palant
2015/03/27 07:29:48
The string isn't escaped yes, meaning that we shou
kzar
2015/03/27 09:50:44
Done.
| |
143 | 143 |
144 # Insert attributes | 144 # Insert attributes |
145 result = escape(result) | 145 result = escape(result) |
146 for tag in self.whitelist: | 146 for tag in self.whitelist: |
147 saved = saved_attributes.get(tag, []) | 147 saved = saved_attributes.get(tag, []) |
148 for attrs in saved: | 148 for attrs in saved: |
149 attrs = map(lambda (name, value): '%s="%s"' % (escape(name), escape(valu e)), attrs) | 149 attrs = map(lambda (name, value): '%s="%s"' % (escape(name), escape(valu e)), attrs) |
150 result = re.sub( | 150 result = re.sub( |
151 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)) , | 151 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)) , |
152 r'<%s %s>\1</%s>' % (tag, " ".join(attrs), tag), | 152 r'<%s %s>\1</%s>' % (tag, " ".join(attrs), tag), |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 stack.pop() | 371 stack.pop() |
372 stack[-1]["subitems"].append(item) | 372 stack[-1]["subitems"].append(item) |
373 stack.append(item) | 373 stack.append(item) |
374 return structured | 374 return structured |
375 | 375 |
376 converters = { | 376 converters = { |
377 "html": RawConverter, | 377 "html": RawConverter, |
378 "md": MarkdownConverter, | 378 "md": MarkdownConverter, |
379 "tmpl": TemplateConverter, | 379 "tmpl": TemplateConverter, |
380 } | 380 } |
LEFT | RIGHT |