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

Side by Side Diff: cms/converters.py

Issue 6596081882234880: Issue 2457 - Don`t escape translatable attributes twice (Closed)
Patch Set: Created May 5, 2015, 2:39 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 # Insert fixed strings 144 # Insert fixed strings
145 for i in range(len(fixed_strings)): 145 for i in range(len(fixed_strings)):
146 result = re.sub(r"\{%d\}" % (i + 1), fixed_strings[i], result, 1) 146 result = re.sub(r"\{%d\}" % (i + 1), fixed_strings[i], result, 1)
147 147
148 # Insert attributes 148 # Insert attributes
149 result = escape(result) 149 result = escape(result)
150 def stringify_attribute((name, value)): 150 def stringify_attribute((name, value)):
151 return '%s="%s"' % ( 151 return '%s="%s"' % (
152 escape(name), 152 escape(name),
153 escape(self.insert_localized_strings(value, escapes)) 153 escape(self.insert_localized_strings(value, {}))
154 ) 154 )
155 155
156 for tag in self.whitelist: 156 for tag in self.whitelist:
157 saved = saved_attributes.get(tag, []) 157 saved = saved_attributes.get(tag, [])
158 for attrs in saved: 158 for attrs in saved:
159 attrs = map(stringify_attribute, attrs) 159 attrs = map(stringify_attribute, attrs)
160 result = re.sub( 160 result = re.sub(
161 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)) , 161 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)) ,
162 r'<%s%s>\1</%s>' % (tag, " " + " ".join(attrs) if attrs else "", tag), 162 r'<%s%s>\1</%s>' % (tag, " " + " ".join(attrs) if attrs else "", tag),
163 result, 1, flags=re.S 163 result, 1, flags=re.S
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 stack.pop() 399 stack.pop()
400 stack[-1]["subitems"].append(item) 400 stack[-1]["subitems"].append(item)
401 stack.append(item) 401 stack.append(item)
402 return structured 402 return structured
403 403
404 converters = { 404 converters = {
405 "html": RawConverter, 405 "html": RawConverter,
406 "md": MarkdownConverter, 406 "md": MarkdownConverter,
407 "tmpl": TemplateConverter, 407 "tmpl": TemplateConverter,
408 } 408 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld