From 82f75776718c8dd52774859d84a5f3dffac39c3d Mon Sep 17 00:00:00 2001 From: mailchuck Date: Sat, 23 Jan 2016 09:53:14 +0100 Subject: [PATCH] Message body display handling of spaces After the changes in the message body renderer, spaces were not correctly handled. Fixes #168 --- src/bitmessageqt/safehtmlparser.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/bitmessageqt/safehtmlparser.py b/src/bitmessageqt/safehtmlparser.py index 5cd869bc..c357662d 100644 --- a/src/bitmessageqt/safehtmlparser.py +++ b/src/bitmessageqt/safehtmlparser.py @@ -17,20 +17,19 @@ class SafeHTMLParser(HTMLParser): 'small', 'sound', 'source', 'spacer', 'span', 'strike', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'time', 'tfoot', 'th', 'thead', 'tr', 'tt', 'u', 'ul', 'var', 'video'] - replaces = [["&", "&"], ["\"", """], ["<", "<"], [">", ">"], ["\n", "
"]] + replaces = [["&", "&"], ["\"", """], ["<", "<"], [">", ">"], ["\n", "
"], ["\t", "    "], [" ", "  "], [" ", "  "], ["
", "
 "]] @staticmethod def multi_replace(text): for a in SafeHTMLParser.replaces: text = text.replace(a[0], a[1]) + if len(text) > 1 and text[0] == " ": + text = " " + text[1:] return text def __init__(self, *args, **kwargs): HTMLParser.__init__(self, *args, **kwargs) - self.elements = set() - self.sanitised = u"" - self.raw = u"" - self.has_html = False + self.reset_safe() def reset_safe(self): self.elements = set()