From 8a00cf61d8693e80fa372f6791c24b2ebe37c3d9 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sat, 15 Nov 2008 08:23:32 +0000 Subject: [PATCH] fix html tag handling. Fixes #4480 --- src/message_textview.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/message_textview.py b/src/message_textview.py index 1f37e3f62..445bc8515 100644 --- a/src/message_textview.py +++ b/src/message_textview.py @@ -230,7 +230,10 @@ class MessageTextView(gtk.TextView): return text for tag in iter.get_toggled_tags(True): - texte += self.begin_tags[tag.get_property('name')] + tag_name = tag.get_property('name') + if tag_name not in self.begin_tags: + continue + texte += self.begin_tags[tag_name] modified = True while (iter.forward_to_tag_toggle(None) and not iter.is_end()): modified = True @@ -240,14 +243,23 @@ class MessageTextView(gtk.TextView): old_tags = [] end_tags = [] for tag in iter.get_toggled_tags(True): - new_tags.append(tag.get_property('name')) + tag_name = tag.get_property('name') + if tag_name not in self.begin_tags: + continue + new_tags.append(tag_name) for tag in iter.get_tags(): - if tag.get_property('name') not in new_tags: - old_tags.append(tag.get_property('name')) + tag_name = tag.get_property('name') + if tag_name not in self.begin_tags or tag_name not in self.end_tags: + continue + if tag_name not in new_tags: + old_tags.append(tag_name) for tag in iter.get_toggled_tags(False): - end_tags.append(tag.get_property('name')) + tag_name = tag.get_property('name') + if tag_name not in self.end_tags: + continue + end_tags.append(tag_name) for tag in old_tags: texte += self.end_tags[tag] @@ -260,7 +272,10 @@ class MessageTextView(gtk.TextView): texte += xhtml_special(buffer.get_text(old, buffer.get_end_iter())) for tag in iter.get_toggled_tags(False): - texte += self.end_tags[tag.get_property('name')] + tag_name = tag.get_property('name') + if tag_name not in self.end_tags: + continue + texte += self.end_tags[tag_name] if modified: return '

' + self.make_clickable_urls(texte) + '

'