[Git][gajim/gajim][master] Handle messages without 'to' correctly
Philipp Hörist
gitlab at dev.gajim.org
Mon Jul 30 22:00:39 CEST 2018
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
85bc3896 by Philipp Hörist at 2018-07-30T19:58:22Z
Handle messages without 'to' correctly
- - - - -
2 changed files:
- gajim/common/modules/carbons.py
- gajim/common/modules/message.py
Changes:
=====================================
gajim/common/modules/carbons.py
=====================================
--- a/gajim/common/modules/carbons.py
+++ b/gajim/common/modules/carbons.py
@@ -73,7 +73,7 @@ def parse_carbon(con, stanza):
type_ = carbon.getName()
to = message.getTo()
frm = message.getFrom()
- log.info('Received type: %s, from: %s, to: %s', type_, to, frm)
+ log.info('Received type: %s, from: %s', type_, frm)
if type_ == 'received':
sent = False
=====================================
gajim/common/modules/message.py
=====================================
--- a/gajim/common/modules/message.py
+++ b/gajim/common/modules/message.py
@@ -58,6 +58,23 @@ class Message:
nbxmpp.NS_IBB])
def _message_received(self, con, stanza):
+ # https://tools.ietf.org/html/rfc6120#section-8.1.1.1
+ # If the stanza does not include a 'to' address then the client MUST
+ # treat it as if the 'to' address were included with a value of the
+ # client's full JID.
+ #
+ # Implementation Note: However, if the client does
+ # check the 'to' address then it is suggested to check at most the
+ # bare JID portion (not the full JID)
+
+ own_jid = self._con.get_own_jid().getStripped()
+ to = stanza.getTo()
+ if to is None:
+ stanza.setTo(own_jid)
+ elif not to.bareMatch(own_jid):
+ log.warning('Message addressed to someone else: %s', stanza)
+ raise nbxmpp.NodeProcessed
+
# Check if a child of the message contains any
# namespaces that we handle in other modules.
# nbxmpp executes less common handlers last
@@ -118,7 +135,7 @@ class Message:
if type_ == 'groupchat':
archive_jid = stanza.getFrom().getStripped()
else:
- archive_jid = self._con.get_own_jid().getStripped()
+ archive_jid = own_jid
if app.logger.find_stanza_id(self._account,
archive_jid,
stanza_id,
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/85bc3896abcb21041bd89c7fefd96927dcfe2ed7
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/85bc3896abcb21041bd89c7fefd96927dcfe2ed7
You're receiving this email because of your account on dev.gajim.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gajim.org/pipermail/commits/attachments/20180730/631fb30b/attachment-0001.html>
More information about the Commits
mailing list