| OLD | NEW |
| 1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 if callback: | 174 if callback: |
| 175 callback(page, locale, name, result, comment, fixed_strings) | 175 callback(page, locale, name, result, comment, fixed_strings) |
| 176 | 176 |
| 177 # Insert fixed strings | 177 # Insert fixed strings |
| 178 for i, fixed_string in enumerate(fixed_strings, 1): | 178 for i, fixed_string in enumerate(fixed_strings, 1): |
| 179 result = result.replace('{{{}}}'.format(i), fixed_string) | 179 result = result.replace('{{{}}}'.format(i), fixed_string) |
| 180 | 180 |
| 181 # Insert attributes | 181 # Insert attributes |
| 182 result = escape(result) | 182 result = escape(result) |
| 183 | 183 |
| 184 def stringify_attribute((name, value)): | 184 def stringify_attribute(attribute): |
| 185 name, value = attribute |
| 185 return '{}="{}"'.format( | 186 return '{}="{}"'.format( |
| 186 escape(name), | 187 escape(name), |
| 187 escape(self.insert_localized_strings(value, {})) | 188 escape(self.insert_localized_strings(value, {})) |
| 188 ) | 189 ) |
| 189 | 190 |
| 190 for tag in self.whitelist: | 191 for tag in self.whitelist: |
| 191 allowed_contents = '(?:[^<>]|{})'.format('|'.join( | 192 allowed_contents = '(?:[^<>]|{})'.format('|'.join( |
| 192 '<(?:{}[^<>]*?|/{})>'.format(t, t) | 193 '<(?:{}[^<>]*?|/{})>'.format(t, t) |
| 193 for t in map(re.escape, self.whitelist - {tag}) | 194 for t in map(re.escape, self.whitelist - {tag}) |
| 194 )) | 195 )) |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 stack[-1]['subitems'].append(item) | 529 stack[-1]['subitems'].append(item) |
| 529 stack.append(item) | 530 stack.append(item) |
| 530 return structured | 531 return structured |
| 531 | 532 |
| 532 | 533 |
| 533 converters = { | 534 converters = { |
| 534 'html': RawConverter, | 535 'html': RawConverter, |
| 535 'md': MarkdownConverter, | 536 'md': MarkdownConverter, |
| 536 'tmpl': TemplateConverter, | 537 'tmpl': TemplateConverter, |
| 537 } | 538 } |
| OLD | NEW |