From aa6738800d67c5061d7e551b3d896f3366296045 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 20 Oct 2011 21:55:24 +0200 Subject: Fix crash on completion of recent words containing xhtml-im attributes fixes #2278 --- src/xhtml.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/xhtml.py') 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: -- cgit v1.2.3