From e74a640fdddf9d18c8692db7f759582a57386e88 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 30 Jan 2012 01:10:41 +0100 Subject: Do not crash when given a link without text (e.g ) --- src/xhtml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/xhtml.py') diff --git a/src/xhtml.py b/src/xhtml.py index e7a045fa..37da5f5d 100644 --- a/src/xhtml.py +++ b/src/xhtml.py @@ -288,9 +288,9 @@ def xhtml_to_poezio_colors(text): for elem in elems: if elem.tag == '{http://www.w3.org/1999/xhtml}a': if 'href' in elem.attrib and elem.attrib['href'] != elem.text: - message += '\x19u%s\x19o (%s)' % (trim(elem.attrib['href']), trim(elem.text)) + message += '\x19u%s\x19o (%s)' % (trim(elem.attrib['href']), trim(elem.text if elem.text else "")) else: - message += '\x19u' + elem.text + '\x19o' + message += '\x19u' + (elem.text if elem.text else "") + '\x19o' elif elem.tag == '{http://www.w3.org/1999/xhtml}blockquote': message += '“' elif elem.tag == '{http://www.w3.org/1999/xhtml}body': -- cgit v1.2.3 From 93c17f8ece0681592aeacd2ac541ba7d2194ebf5 Mon Sep 17 00:00:00 2001 From: mathieui Date: Tue, 7 Feb 2012 21:47:40 +0100 Subject: Fixed #2328 --- src/xhtml.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/xhtml.py') diff --git a/src/xhtml.py b/src/xhtml.py index 37da5f5d..cf7a5fc0 100644 --- a/src/xhtml.py +++ b/src/xhtml.py @@ -194,7 +194,9 @@ def get_body_from_message_stanza(message): if config.get('enable_xhtml_im', 'true') == 'true': xhtml_body = message['xhtml_im'] if xhtml_body: - return xhtml_to_poezio_colors(xhtml_body) + content = xhtml_to_poezio_colors(xhtml_body) + content = content if content else message['body'] + return content or " " return message['body'] def ncurses_color_to_html(color): -- cgit v1.2.3