summaryrefslogtreecommitdiff
path: root/src/xhtml.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-10-20 21:55:24 +0200
committerFlorent Le Coz <louiz@louiz.org>2011-10-20 21:55:24 +0200
commitaa6738800d67c5061d7e551b3d896f3366296045 (patch)
tree769beed98d0b407282e155a02789e9f8e05e9d0d /src/xhtml.py
parent354006a850490cdbf9a598d237ac78f084114e72 (diff)
downloadpoezio-aa6738800d67c5061d7e551b3d896f3366296045.tar.gz
poezio-aa6738800d67c5061d7e551b3d896f3366296045.tar.bz2
poezio-aa6738800d67c5061d7e551b3d896f3366296045.tar.xz
poezio-aa6738800d67c5061d7e551b3d896f3366296045.zip
Fix crash on completion of recent words containing xhtml-im attributes
fixes #2278
Diffstat (limited to 'src/xhtml.py')
-rw-r--r--src/xhtml.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/xhtml.py b/src/xhtml.py
index c14382b8..38239d18 100644
--- a/src/xhtml.py
+++ b/src/xhtml.py
@@ -176,6 +176,8 @@ log = logging.getLogger(__name__)
whitespace_re = re.compile(r'\s+')
+xhtml_attr_re = re.compile(r'\x19\d{0,3}\}|\x19[buaio]')
+
def get_body_from_message_stanza(message):
"""
Returns a string with xhtml markups converted to
@@ -321,9 +323,18 @@ def xhtml_to_poezio_colors(text):
return message
-def clean_text(string):
+def clean_text(s):
+ """
+ Remove all xhtml-im attributes (\x19etc) from the string with the
+ complete color format, i.e \x19xxx}
+ """
+ s = re.sub(xhtml_attr_re, "", s)
+ return s
+
+def clean_text_simple(string):
"""
- Remove all \x19 from the string
+ Remove all \x19 from the string formatted with simple colors:
+ \x198
"""
pos = string.find('\x19')
while pos != -1: