From 04a3aa0e493244f72e6e11ab5a6d90e0f7133459 Mon Sep 17 00:00:00 2001 From: souliane Date: Wed, 2 Dec 2015 09:57:14 +0100 Subject: [PATCH] stdui (contact_list): use jid.JID to check the JID instead of an approximative regex --- src/stdui/ui_contact_list.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/stdui/ui_contact_list.py b/src/stdui/ui_contact_list.py index 586ab309..d3b8d3e4 100644 --- a/src/stdui/ui_contact_list.py +++ b/src/stdui/ui_contact_list.py @@ -224,7 +224,9 @@ class ContactList(object): @return dict """ contact_jid_s = data[xml_tools.formEscape('contact_jid')] - if not re.match(r'^.+@.+\..+', contact_jid_s, re.IGNORECASE): + try: + contact_jid = jid.JID(contact_jid_s) + except (RuntimeError, jid.InvalidFormat, AttributeError): # TODO: replace '\t' by a constant (see tools.xmlui.XMLUI.onFormSubmitted) data['selected_groups'] = data[xml_tools.formEscape('groups_list')].split('\t') options = {'id': self.__add_id, @@ -232,7 +234,6 @@ class ContactList(object): 'contact_text': D_('Please enter a valid JID (like "contact@%s"):') % self.default_host, } return self.getDialogXMLUI(options, data, profile) - contact_jid = jid.JID(contact_jid_s) self.host.addContact(contact_jid, profile_key=profile) return self._updateContact(data, profile) # after adding, updating