diff options
| author | Linus Jahn <lnj@kaidan.im> | 2019-02-01 18:10:30 +0100 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2019-05-05 14:35:55 +0200 |
| commit | 58ee9cf0fbf128b66b6297b2505a4df1deded916 (patch) | |
| tree | c7efa2a12d6257e76904fcb1caac0a19084718dd /src/client/QXmppMessageReceiptManager.cpp | |
| parent | 9c8fea86564712aca4363bb1ebe5fd227eff188f (diff) | |
| download | qxmpp-58ee9cf0fbf128b66b6297b2505a4df1deded916.tar.gz | |
MessageReceiptManager: Don't accept receipts from other resources
There were some problems with buggy clients leading to that some
messages were already marked as received, even though only another
resource of the used account has got the message.
Here is an example:
[outgoing]:
<message id="tH9OkRw"
to="42@example.com"
from="lnj@kaidan.im/kaidan.PR29"
type="chat">
<body>test</body>
<n1:request xmlns:n1="urn:xmpp:receipts"/>
</message>
[incoming]:
<message to="lnj@kaidan.im/kaidan.PR29"
from="lnj@kaidan.im/dino.dc02d539"
id="410b33c3-1cd3-433e-8699-74a7583c2560">
<n1:received xmlns="urn:xmpp:receipts" id="tH9OkRw"/>
</message>
Here the other client "dino.dc02d539" sent an <received/> tag, although
it actually received this message over carbons. To avoid that we need to
ignore messages also from our bare JID.
Diffstat (limited to 'src/client/QXmppMessageReceiptManager.cpp')
| -rw-r--r-- | src/client/QXmppMessageReceiptManager.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/client/QXmppMessageReceiptManager.cpp b/src/client/QXmppMessageReceiptManager.cpp index 2abe32a6..c010eadf 100644 --- a/src/client/QXmppMessageReceiptManager.cpp +++ b/src/client/QXmppMessageReceiptManager.cpp @@ -29,6 +29,7 @@ #include "QXmppConstants_p.h" #include "QXmppMessage.h" #include "QXmppClient.h" +#include "QXmppUtils.h" /// Constructs a QXmppMessageReceiptManager to handle incoming and outgoing /// message delivery receipts. @@ -54,7 +55,12 @@ bool QXmppMessageReceiptManager::handleStanza(const QDomElement &stanza) // Handle receipts and cancel any further processing. if (!message.receiptId().isEmpty()) { - emit messageDelivered(message.from(), message.receiptId()); + // Buggy clients also mark carbon messages as received; to avoid this + // we check whether sender and receiver have the same bare JID. + if (QXmppUtils::jidToBareJid(message.from()) + != QXmppUtils::jidToBareJid(message.to())) { + emit messageDelivered(message.from(), message.receiptId()); + } return true; } |
