summaryrefslogtreecommitdiff
path: root/poezio/xhtml.py
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-11-26 17:57:51 +0000
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-11-26 17:57:51 +0000
commitefc2ebe2c4eaabd061139a16efb403368f9f82e0 (patch)
tree3642d2fe647f3fca3cb081083341824e71e50ed9 /poezio/xhtml.py
parentc8b2d2650f8d37e87788b8f37236e96dd374ac77 (diff)
downloadpoezio-efc2ebe2c4eaabd061139a16efb403368f9f82e0.tar.gz
poezio-efc2ebe2c4eaabd061139a16efb403368f9f82e0.tar.bz2
poezio-efc2ebe2c4eaabd061139a16efb403368f9f82e0.tar.xz
poezio-efc2ebe2c4eaabd061139a16efb403368f9f82e0.zip
XHTML-IM: Check for the existence of elements manually.
This fixes part of #3186, slixmpp was previously adding a new XHTML-IM payload whenever we just wanted to check for its presence. Also makes the code abort faster in the common case where no XHTML-IM element is present.
Diffstat (limited to 'poezio/xhtml.py')
-rw-r--r--poezio/xhtml.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/poezio/xhtml.py b/poezio/xhtml.py
index 0b774494..6ab48733 100644
--- a/poezio/xhtml.py
+++ b/poezio/xhtml.py
@@ -195,15 +195,18 @@ def get_body_from_message_stanza(message, use_xhtml=False,
poezio colors if there's an xhtml_im element, or
the body (without any color) otherwise
"""
- if use_xhtml:
- xhtml = message['html'].xml
- xhtml_body = xhtml.find('{http://www.w3.org/1999/xhtml}body')
- if xhtml_body:
- content = xhtml_to_poezio_colors(xhtml_body, tmp_dir=tmp_dir,
- extract_images=extract_images)
- content = content if content else message['body']
- return content or " "
- return message['body']
+ if not use_xhtml:
+ return message['body']
+ xhtml = message.xml.find('{http://jabber.org/protocol/xhtml-im}html')
+ if not xhtml:
+ return message['body']
+ xhtml_body = xhtml.find('{http://www.w3.org/1999/xhtml}body')
+ if not xhtml_body:
+ return message['body']
+ content = xhtml_to_poezio_colors(xhtml_body, tmp_dir=tmp_dir,
+ extract_images=extract_images)
+ content = content if content else message['body']
+ return content or " "
def ncurses_color_to_html(color):
"""