From a3564b7aca44f5ccab3881e6f723dfb64bf66884 Mon Sep 17 00:00:00 2001
From: Mili Verma <mili.verma@isode.com>
Date: Mon, 22 Jun 2015 14:06:58 +0100
Subject: Remove when sending an empty response

In RFC 6120, there are only 2 places where "=" is allowed - in the initial
client auth and in the final server success response.

While testing challenge response exchanges in Kerberos, it was seen that Swift
was adding an '=' in other empty responses. This patch fixes it by sending an
empty response instead of an '='.

Test-information:
Tested on Windows using a WIP GSSAPI authentication exchange with M-Link.

Change-Id: I1f82bddbd1380361cbe43e45a2804156249582ae

diff --git a/Swiften/Serializer/AuthResponseSerializer.cpp b/Swiften/Serializer/AuthResponseSerializer.cpp
index 9c9418b..818c6d4 100644
--- a/Swiften/Serializer/AuthResponseSerializer.cpp
+++ b/Swiften/Serializer/AuthResponseSerializer.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2014 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
  * All rights reserved.
  * See the COPYING file for more information.
  */
@@ -22,7 +22,7 @@ SafeByteArray AuthResponseSerializer::serialize(boost::shared_ptr<ToplevelElemen
 	boost::optional<SafeByteArray> message = authResponse->getValue();
 	if (message) {
 		if ((*message).empty()) {
-			value = createSafeByteArray("=");
+			value = createSafeByteArray("");
 		}
 		else {
 			value = Base64::encode(*message);
diff --git a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
index 65508d0..4dfb04d 100644
--- a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
  * All rights reserved.
  * See the COPYING file for more information.
  */
@@ -49,7 +49,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture {
 
 			CPPUNIT_ASSERT_EQUAL(createSafeByteArray(
 				"<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
-					"="
+					""
 				"</response>"), testling.serialize(authResponse));
 		}
 };
-- 
cgit v0.10.2-6-g49f6