summaryrefslogtreecommitdiff
path: root/src/xhtml.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/xhtml.py')
-rw-r--r--src/xhtml.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/xhtml.py b/src/xhtml.py
index 01e2dfcd..b84ce943 100644
--- a/src/xhtml.py
+++ b/src/xhtml.py
@@ -183,6 +183,8 @@ 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_color_double = re.compile(r'(?:\x19\d+}|\x19\d)+(\x19\d|\x19\d+})')
+poezio_format_trim = re.compile(r'(\x19\d+}|\x19\d|\x19[buaio]|\x19o)+\x19o')
xhtml_simple_attr_re = re.compile(r'\x19\d')
@@ -303,7 +305,8 @@ class XHTMLHandler(sax.ContentHandler):
@property
def result(self):
- return ''.join(self.builder).strip()
+ sanitized = re.sub(poezio_color_double, r'\1', ''.join(self.builder).strip())
+ return re.sub(poezio_format_trim, '\x19o', sanitized)
def append_formatting(self, formatting):
self.formatting.append(formatting)