aboutsummaryrefslogtreecommitdiff
path: root/src/QXmppIncomingClient.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-08-28 22:59:55 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-08-28 22:59:55 +0000
commit13b245f3bcc709b2a974b764bb209e1ea87768af (patch)
treeb3bbde11e5fd231bf059f09f308dddf776426a47 /src/QXmppIncomingClient.cpp
parent8b58bfd72ad5d8e28e325c6cea61db270b9e626b (diff)
downloadqxmpp-13b245f3bcc709b2a974b764bb209e1ea87768af.tar.gz
update QXmppServer extensions API
Diffstat (limited to 'src/QXmppIncomingClient.cpp')
-rw-r--r--src/QXmppIncomingClient.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/QXmppIncomingClient.cpp b/src/QXmppIncomingClient.cpp
index ace50158..f70d6edf 100644
--- a/src/QXmppIncomingClient.cpp
+++ b/src/QXmppIncomingClient.cpp
@@ -298,16 +298,37 @@ void QXmppIncomingClient::handleStanza(const QDomElement &nodeRecv)
}
}
- // unhandled stanza, emit it
+ // check the sender is legitimate
+ const QString from = nodeRecv.attribute("from");
+ if (!from.isEmpty() && from != jid() && from != jidToBareJid(jid()))
+ {
+ warning(QString("Received a stanza from unexpected JID %1").arg(from));
+ return;
+ }
+
+ // process unhandled stanzas
if (nodeRecv.tagName() == "iq" ||
nodeRecv.tagName() == "message" ||
nodeRecv.tagName() == "presence")
{
QDomElement nodeFull(nodeRecv);
- nodeFull.setAttribute("from", jid());
+
+ // if the sender is empty, set it to the appropriate JID
+ if (nodeFull.attribute("from").isEmpty())
+ {
+ if (nodeFull.tagName() == "presence" &&
+ (nodeFull.attribute("type") == "subscribe" ||
+ nodeFull.attribute("type") == "subscribed"))
+ nodeFull.setAttribute("from", jidToBareJid(jid()));
+ else
+ nodeFull.setAttribute("from", jid());
+ }
+
// if the recipient is empty, set it to the local domain
if (nodeFull.attribute("to").isEmpty())
nodeFull.setAttribute("to", d->domain);
+
+ // emit stanza for processing by server
emit elementReceived(nodeFull);
}
}