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

Unified Diff: cms/converters.py

Issue 6274620759998464: Issue 2450 - [cms] Extra semicolons being added to translatable strings (Closed)
Patch Set: More generic regexp Created May 5, 2015, 2:25 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/converters.py
===================================================================
--- a/cms/converters.py
+++ b/cms/converters.py
@@ -54,16 +54,20 @@ class AttributeParser(HTMLParser.HTMLPar
def parse(self, text, pagename):
self.reset()
self._string = []
self._fixed_strings = []
self._inside_fixed = False
self._attrs = {}
self._pagename = pagename
+ # Force-escape ampersands, otherwise the parser will autocomplete bogus
+ # entities.
+ text = re.sub(r"&(?!\S+;)", "&", text)
+
try:
self.feed(text)
return "".join(self._string), self._attrs, ["".join(s) for s in self._fixed_strings]
finally:
self._string = None
self._attrs = None
self._pagename = None
self._inside_fixed = False
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld