summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Queries/Request.cpp6
-rw-r--r--Swiften/Queries/UnitTest/RequestTest.cpp15
2 files changed, 21 insertions, 0 deletions
diff --git a/Swiften/Queries/Request.cpp b/Swiften/Queries/Request.cpp
index f3f56c9..422f36c 100644
--- a/Swiften/Queries/Request.cpp
+++ b/Swiften/Queries/Request.cpp
@@ -7,6 +7,7 @@
#include <Swiften/Queries/Request.h>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Elements/RawXMLPayload.h>
+#include <Swiften/Base/Log.h>
namespace Swift {
@@ -75,6 +76,11 @@ bool Request::handleIQ(boost::shared_ptr<IQ> iq) {
bool Request::isCorrectSender(const JID& jid) {
if (router_->isAccountJID(receiver_)) {
+ if (jid.isValid() && jid.equals(router_->getJID(), JID::WithResource)) {
+ // This unspecified behavior seems to happen in ejabberd versions (e.g. 2.0.5)
+ SWIFT_LOG(warning) << "Server responded to an account request with a full JID, which is not allowed. Handling it anyway.";
+ return true;
+ }
return router_->isAccountJID(jid);
}
else {
diff --git a/Swiften/Queries/UnitTest/RequestTest.cpp b/Swiften/Queries/UnitTest/RequestTest.cpp
index cf9b381..6c2a805 100644
--- a/Swiften/Queries/UnitTest/RequestTest.cpp
+++ b/Swiften/Queries/UnitTest/RequestTest.cpp
@@ -37,6 +37,7 @@ class RequestTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testHandleIQ_ServerRespondsWithDomain);
CPPUNIT_TEST(testHandleIQ_ServerRespondsWithBareJID);
CPPUNIT_TEST(testHandleIQ_ServerRespondsWithoutFrom);
+ CPPUNIT_TEST(testHandleIQ_ServerRespondsWithFullJID);
CPPUNIT_TEST_SUITE_END();
public:
@@ -283,6 +284,20 @@ class RequestTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
}
+ // This tests a bug in ejabberd servers (2.0.5)
+ void testHandleIQ_ServerRespondsWithFullJID() {
+ MyRequest testling(IQ::Get, JID(), payload_, router_);
+ router_->setJID("alice@wonderland.lit/TeaParty");
+ testling.onResponse.connect(boost::bind(&RequestTest::handleResponse, this, _1, _2));
+ testling.send();
+
+ channel_->onIQReceived(createResponse(JID("alice@wonderland.lit/TeaParty"),"test-id"));
+
+ CPPUNIT_ASSERT_EQUAL(1, responsesReceived_);
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(receivedErrors.size()));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
+ }
+
void testHandleIQ_ServerRespondsWithoutFrom() {
MyRequest testling(IQ::Get, JID(), payload_, router_);
router_->setJID("alice@wonderland.lit/TeaParty");