From 294face2904965837f40cd363446014592d95ac0 Mon Sep 17 00:00:00 2001
From: Philipp Balzarek
Date: Tue, 11 Mar 2014 17:34:08 +0100
Subject: [PATCH] =?UTF-8?q?implement=20=C2=A76.4.2=20(send=20single=20equa?=
=?UTF-8?q?ls=20sign)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Instead of an inital payload, send a single equals sign.
( https://tools.ietf.org/html/rfc6120#section-6.4.2 )
---
source/Network/Xmpp/Sasl/Common.hs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/source/Network/Xmpp/Sasl/Common.hs b/source/Network/Xmpp/Sasl/Common.hs
index 5ab11af..b2b4e47 100644
--- a/source/Network/Xmpp/Sasl/Common.hs
+++ b/source/Network/Xmpp/Sasl/Common.hs
@@ -134,10 +134,14 @@ quote x = BS.concat ["\"",x,"\""]
saslInit :: Text.Text -> Maybe BS.ByteString -> ErrorT AuthFailure (StateT StreamState IO) ()
saslInit mechanism payload = do
r <- lift . pushElement . saslInitE mechanism $
- Text.decodeUtf8 . B64.encode <$> payload
+ Text.decodeUtf8 . encodeEmpty . B64.encode <$> payload
case r of
Right () -> return ()
Left e -> throwError $ AuthStreamFailure e
+ where
+ -- ยง6.4.2
+ encodeEmpty "" = "="
+ encodeEmpty x = x
-- | Pull the next element.
pullSaslElement :: ErrorT AuthFailure (StateT StreamState IO) SaslElement