stdui (contact_list): use jid.JID to check the JID instead of an approximative regex

This commit is contained in:
souliane 2015-12-02 09:57:14 +01:00
commit 04a3aa0e49

View file

@ -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