summaryrefslogtreecommitdiff
path: root/src/xhtml.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-01-30 01:10:41 +0100
committermathieui <mathieui@mathieui.net>2012-01-30 01:10:41 +0100
commite74a640fdddf9d18c8692db7f759582a57386e88 (patch)
treefd2284abf109841a63f791314773cc8d3131fd01 /src/xhtml.py
parent2dc7af10fbb3edd54bbdc3b0d65c6728078fa4b7 (diff)
downloadpoezio-e74a640fdddf9d18c8692db7f759582a57386e88.tar.gz
poezio-e74a640fdddf9d18c8692db7f759582a57386e88.tar.bz2
poezio-e74a640fdddf9d18c8692db7f759582a57386e88.tar.xz
poezio-e74a640fdddf9d18c8692db7f759582a57386e88.zip
Do not crash when given a link without text
(e.g <a href="example.com"/>)
Diffstat (limited to 'src/xhtml.py')
-rw-r--r--src/xhtml.py4
1 files changed, 2 insertions, 2 deletions
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':