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