From afb15500e083d48a834882c984cfbe95a280830f Mon Sep 17 00:00:00 2001 From: Dimitur Kirov Date: Thu, 21 Jul 2005 14:09:17 +0000 Subject: [PATCH] Escape markup in contact status and Resource (Tooltip) --- src/dialogs.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/dialogs.py b/src/dialogs.py index 9c853214f..3ac2f7611 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -516,7 +516,6 @@ class RosterTooltip(gtk.Window): self.connect('motion-notify-event', self.motion_notify_event) - def motion_notify_event(self, widget, event): self.hide_tooltip() @@ -579,10 +578,12 @@ class RosterTooltip(gtk.Window): if os.path.exists(file): image.set_from_file(file) break + image.set_alignment(0.01, 1) self.table.attach(spacer, 1, 2, self.current_row, self.current_row + 1, 0, 0, 0, 0) self.table.attach(image,2,3,self.current_row, self.current_row + 1, 0, 0, 3, 0) + image.set_alignment(0.01, 1) str_status = resource + ' ('+str(priority)+')' if status: status = status.strip() @@ -592,7 +593,11 @@ class RosterTooltip(gtk.Window): status_label.set_alignment(00, 0) self.table.attach(status_label, 3, 4, self.current_row, self.current_row + 1, gtk.EXPAND | gtk.FILL, 0, 0, 0) - + + def escape_entities(self, text): + # escapes markup entities + return text.replace('&', '&').replace('>','>').replace('<','<') + def populate(self, contacts): if not contacts or len(contacts) == 0: return @@ -639,9 +644,9 @@ class RosterTooltip(gtk.Window): info = '' + prim_contact.jid + '' info += '\n' + _('Name: ') + '' + \ - prim_contact.name + self.escape_entities(prim_contact.name) info += '\n' + _('Subscription: ') + '' + \ - prim_contact.sub + self.escape_entities(prim_contact.sub) if prim_contact.keyID: keyID = None @@ -651,7 +656,7 @@ class RosterTooltip(gtk.Window): keyID = prim_contact.keyID[8:] if keyID: info += '\n' + _('OpenPGP: ') + \ - '' + keyID + '' + self.escape_entities(keyID ) single_line, resource_str, multiple_resource= '', '', False num_resources = 0 @@ -670,15 +675,16 @@ class RosterTooltip(gtk.Window): else: # only one resource if contact.resource: info += '\n' + _('Resource: ') + \ - '' + contact.resource + ' (' + str(contact.priority) + ')' + '' + self.escape_entities(contact.resource) + ' (' + str(contact.priority) + ')' if contact.show: info += '\n' + _('Status: ') + \ '' + helpers.get_uf_show(contact.show) if contact.status: status = contact.status.strip() if status != '': - info += ' - ' + status - + # escape markup entities. Is it posible to have markup in status? + info += ' - ' + self.escape_entities(status) + self.account.set_markup(info) class InputDialog: