Mercurial > libervia-backend
comparison src/stdui/ui_contact_list.py @ 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 | 62d6310e7c04 |
children | d17772b0fe22 |
comparison
equal
deleted
inserted
replaced
1713:0d972af37ff5 | 1714:0b4c1f6ada52 |
---|---|
222 @param data (dict) | 222 @param data (dict) |
223 @param profile: %(doc_profile)s | 223 @param profile: %(doc_profile)s |
224 @return dict | 224 @return dict |
225 """ | 225 """ |
226 contact_jid_s = data[xml_tools.formEscape('contact_jid')] | 226 contact_jid_s = data[xml_tools.formEscape('contact_jid')] |
227 if not re.match(r'^.+@.+\..+', contact_jid_s, re.IGNORECASE): | 227 try: |
228 contact_jid = jid.JID(contact_jid_s) | |
229 except (RuntimeError, jid.InvalidFormat, AttributeError): | |
228 # TODO: replace '\t' by a constant (see tools.xmlui.XMLUI.onFormSubmitted) | 230 # TODO: replace '\t' by a constant (see tools.xmlui.XMLUI.onFormSubmitted) |
229 data['selected_groups'] = data[xml_tools.formEscape('groups_list')].split('\t') | 231 data['selected_groups'] = data[xml_tools.formEscape('groups_list')].split('\t') |
230 options = {'id': self.__add_id, | 232 options = {'id': self.__add_id, |
231 'title': D_('Add contact'), | 233 'title': D_('Add contact'), |
232 'contact_text': D_('Please enter a valid JID (like "contact@%s"):') % self.default_host, | 234 'contact_text': D_('Please enter a valid JID (like "contact@%s"):') % self.default_host, |
233 } | 235 } |
234 return self.getDialogXMLUI(options, data, profile) | 236 return self.getDialogXMLUI(options, data, profile) |
235 contact_jid = jid.JID(contact_jid_s) | |
236 self.host.addContact(contact_jid, profile_key=profile) | 237 self.host.addContact(contact_jid, profile_key=profile) |
237 return self._updateContact(data, profile) # after adding, updating | 238 return self._updateContact(data, profile) # after adding, updating |
238 | 239 |
239 def _updateContact(self, data, profile): | 240 def _updateContact(self, data, profile): |
240 """Update the selected contact | 241 """Update the selected contact |