diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-28 22:59:55 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-28 22:59:55 +0000 |
| commit | 13b245f3bcc709b2a974b764bb209e1ea87768af (patch) | |
| tree | b3bbde11e5fd231bf059f09f308dddf776426a47 /src/QXmppIncomingClient.cpp | |
| parent | 8b58bfd72ad5d8e28e325c6cea61db270b9e626b (diff) | |
| download | qxmpp-13b245f3bcc709b2a974b764bb209e1ea87768af.tar.gz | |
update QXmppServer extensions API
Diffstat (limited to 'src/QXmppIncomingClient.cpp')
| -rw-r--r-- | src/QXmppIncomingClient.cpp | 25 |
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); } } |
