From 4b8749ca88ef5a7e525231893b813eb0d4b2f8c1 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 8 Dec 2014 03:09:21 +0100 Subject: Sanitize the XHTML output by removing useless formatting chars --- src/xhtml.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/xhtml.py b/src/xhtml.py index 01e2dfcd..5b71823c 100644 --- a/src/xhtml.py +++ b/src/xhtml.py @@ -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) -- cgit v1.2.3