Sanitize the XHTML output by removing useless formatting chars

This commit is contained in:
mathieui 2014-12-08 03:09:21 +01:00
parent e1543545ad
commit 4b8749ca88
No known key found for this signature in database
GPG key ID: C59F84CEEFD616E3

View file

@ -183,6 +183,7 @@ whitespace_re = re.compile(r'\s+')
xhtml_attr_re = re.compile(r'\x19-?\d[^}]*}|\x19[buaio]')
xhtml_data_re = re.compile(r'data:image/([a-z]+);base64,(.+)')
poezio_colors_trim = re.compile(r'\x19o(\x19\d+}|\x19\d|\x19[buaio])*\x19o')
xhtml_simple_attr_re = re.compile(r'\x19\d')
@ -303,7 +304,7 @@ class XHTMLHandler(sax.ContentHandler):
@property
def result(self):
return ''.join(self.builder).strip()
return re.sub(poezio_colors_trim, '\x19o', ''.join(self.builder).strip())
def append_formatting(self, formatting):
self.formatting.append(formatting)