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

Delta Between Two Patch Sets: cms/converters.py

Issue 5144941147717632: Issue 2112 - Support fixed text in strings. (Closed)
Left Patch Set: Addressed feedback. Created March 26, 2015, 10:09 p.m.
Right Patch Set: Avoid escaping search string for fixed strings. Created March 27, 2015, 9:49 a.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 | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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
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 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld