diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-08-28 10:01:54 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-08-28 10:01:54 (GMT) |
commit | b1a9a1b61ebce0f64d656006a85607c8c8491f4a (patch) | |
tree | a3157084893c6fa0f41f85a4de1b36f280334c02 /Swiften/Queries/Request.cpp | |
parent | 66f820c2c7e2d7c6d883c995bf7b2da37aa963c7 (diff) | |
parent | 2faca4242e4de2568eb917df83fd1b9c21f33897 (diff) | |
download | swift-contrib-b1a9a1b61ebce0f64d656006a85607c8c8491f4a.zip swift-contrib-b1a9a1b61ebce0f64d656006a85607c8c8491f4a.tar.bz2 |
Merge branch 'swift-1.x'
* swift-1.x:
Remove relaxation of not checking JIDs if the IQRouter's JID isn't set.
Fixed Request::isAccountJID().
Check sender on incoming IQ responses.
Diffstat (limited to 'Swiften/Queries/Request.cpp')
-rw-r--r-- | Swiften/Queries/Request.cpp | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/Swiften/Queries/Request.cpp b/Swiften/Queries/Request.cpp index 359c6a6..0126d62 100644 --- a/Swiften/Queries/Request.cpp +++ b/Swiften/Queries/Request.cpp @@ -41,27 +41,42 @@ bool Request::handleIQ(boost::shared_ptr<IQ> iq) { bool handled = false; if (iq->getType() == IQ::Result || iq->getType() == IQ::Error) { if (sent_ && iq->getID() == id_) { - if (iq->getType() == IQ::Result) { - boost::shared_ptr<Payload> payload = iq->getPayloadOfSameType(payload_); - if (!payload && boost::dynamic_pointer_cast<RawXMLPayload>(payload_) && !iq->getPayloads().empty()) { - payload = iq->getPayloads().front(); - } - handleResponse(payload, ErrorPayload::ref()); - } - else { - ErrorPayload::ref errorPayload = iq->getPayload<ErrorPayload>(); - if (errorPayload) { - handleResponse(boost::shared_ptr<Payload>(), errorPayload); + if (isCorrectSender(iq->getFrom())) { + if (iq->getType() == IQ::Result) { + boost::shared_ptr<Payload> payload = iq->getPayloadOfSameType(payload_); + if (!payload && boost::dynamic_pointer_cast<RawXMLPayload>(payload_) && !iq->getPayloads().empty()) { + payload = iq->getPayloads().front(); + } + handleResponse(payload, ErrorPayload::ref()); } else { - handleResponse(boost::shared_ptr<Payload>(), ErrorPayload::ref(new ErrorPayload(ErrorPayload::UndefinedCondition))); + ErrorPayload::ref errorPayload = iq->getPayload<ErrorPayload>(); + if (errorPayload) { + handleResponse(boost::shared_ptr<Payload>(), errorPayload); + } + else { + handleResponse(boost::shared_ptr<Payload>(), ErrorPayload::ref(new ErrorPayload(ErrorPayload::UndefinedCondition))); + } } + router_->removeHandler(this); + handled = true; } - router_->removeHandler(this); - handled = true; } } return handled; } +bool Request::isCorrectSender(const JID& jid) { + if (isAccountJID(receiver_)) { + return isAccountJID(jid); + } + else { + return jid.equals(receiver_, JID::WithResource); + } +} + +bool Request::isAccountJID(const JID& jid) { + return jid.isValid() ? router_->getJID().toBare().equals(jid, JID::WithResource) : true; +} + } |