From 834546ac7752e3e5c65d31e900489df2c85ce298 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 6 Jun 2013 22:53:43 +0200 Subject: [PATCH] Do not traceback when receiving malformed XML in a xhtml-im body --- src/xhtml.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/xhtml.py b/src/xhtml.py index 1deca67a..e34ea3e7 100644 --- a/src/xhtml.py +++ b/src/xhtml.py @@ -227,7 +227,11 @@ def ncurses_color_to_html(color): def xhtml_to_poezio_colors(xml): if isinstance(xml, str): - xml = ET.fromstring(xml) + try: + xml = ET.fromstring(xml) + except cElementTree.ParserError as e: + log.error("Error decoding XML: [%s] (%s)" % (xml, e)) + return "" def parse_css(css): def get_color(value): if value[0] == '#':