Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Leboulanger <asterix@lagaule.org>2008-12-13 17:43:46 +0300
committerYann Leboulanger <asterix@lagaule.org>2008-12-13 17:43:46 +0300
commitd0c3b6fd440f523ba6a213e674420060cf413e08 (patch)
treed28d7ff28d0899a452cec39fe0afe9118940a34b
parentd820977e1683884bf68dda720c923b8ced83e860 (diff)
prevent sending messages to invalid JIDs. Fixes #4577
-rw-r--r--src/common/connection.py8
-rw-r--r--src/common/connection_handlers.py8
-rw-r--r--src/dialogs.py7
3 files changed, 21 insertions, 2 deletions
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()