Mercurial > libervia-backend
changeset 1714:0b4c1f6ada52
stdui (contact_list): use jid.JID to check the JID instead of an approximative regex
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 02 Dec 2015 09:57:14 +0100 |
parents | 0d972af37ff5 |
children | b505b01195f0 |
files | src/stdui/ui_contact_list.py |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/stdui/ui_contact_list.py Wed Dec 02 09:10:58 2015 +0100 +++ b/src/stdui/ui_contact_list.py Wed Dec 02 09:57:14 2015 +0100 @@ -224,7 +224,9 @@ @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 @@ '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