diff --git a/src/common/connection.py b/src/common/connection.py index 0393201d59795cf196cd516e088d282f88b4b35b..fa68745dc6c6437e878df19bb27be24eb474a17d 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 c463b62191c8654387d354ea8534d40b0b496be8..2531d267082f8214550b701f9de6d44f170db669 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 79613b0a927fa4edd77c38448553730a283d4bb1..7fcd44f406b318fbe93aad958e243adf076a9087 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()