diff --git a/src/common/connection.py b/src/common/connection.py index 0393201d5..fa68745dc 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1074,6 +1074,14 @@ class Connection(ConnectionHandlers): original_message=None, delayed=None): if not self.connection: return 1 + try: + jid = helpers.parse_jid(jid) + except helpers.InvalidFormat: + self.dispatch('ERROR', (_('Invalid Jabber ID'), + _('It is not possible to send a message to %s, this JID is not ' + 'valid.') % jid)) + return + if msg and not xhtml and gajim.config.get( 'rst_formatting_outgoing_messages'): from common.rst_xhtml_generator import create_xhtml diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index c463b6219..2531d2670 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1682,8 +1682,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, self._HttpAuthCB(con, msg) return - frm = helpers.get_full_jid_from_iq(msg) - jid = helpers.get_jid_from_iq(msg) + try: + frm = helpers.get_full_jid_from_iq(msg) + jid = helpers.get_jid_from_iq(msg) + except helpers.InvalidFormat: + self.dispatch('ERROR', (_('Invalid Jabber ID'), + _('A message from a non-valid JID arrived, it has been ignored.'))) addressTag = msg.getTag('addresses', namespace = common.xmpp.NS_ADDRESS) diff --git a/src/dialogs.py b/src/dialogs.py index 79613b0a9..7fcd44f40 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -2352,6 +2352,13 @@ class SingleMessageWindow: for to_whom_jid in sender_list: if to_whom_jid in self.completion_dict: to_whom_jid = self.completion_dict[to_whom_jid].jid + try: + to_whom_jid = helpers.parse_jid(to_whom_jid) + except helpers.InvalidFormat: + ErrorDialog(_('Invalid Jabber ID'), + _('It is not possible to send a message to %s, this JID is not ' + 'valid.') % to_whom_jid) + return subject = self.subject_entry.get_text().decode('utf-8') begin, end = self.message_tv_buffer.get_bounds()