From c1357717d952999a0aca7d96bf15d72ada01e75b Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 9 Feb 2012 22:01:11 -0800 Subject: [PATCH] Use '=' as base64 value for empty string SASL results. --- sleekxmpp/features/feature_mechanisms/stanza/auth.py | 5 ++++- sleekxmpp/features/feature_mechanisms/stanza/challenge.py | 5 ++++- sleekxmpp/features/feature_mechanisms/stanza/response.py | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sleekxmpp/features/feature_mechanisms/stanza/auth.py b/sleekxmpp/features/feature_mechanisms/stanza/auth.py index d2a981f..a366f72 100644 --- a/sleekxmpp/features/feature_mechanisms/stanza/auth.py +++ b/sleekxmpp/features/feature_mechanisms/stanza/auth.py @@ -41,7 +41,10 @@ class Auth(StanzaBase): def set_value(self, values): if not self['mechanism'] in self.plain_mechs: - self.xml.text = bytes(base64.b64encode(values)).decode('utf-8') + if values: + self.xml.text = bytes(base64.b64encode(values)).decode('utf-8') + else: + self.xml.text = '=' else: self.xml.text = bytes(values).decode('utf-8') diff --git a/sleekxmpp/features/feature_mechanisms/stanza/challenge.py b/sleekxmpp/features/feature_mechanisms/stanza/challenge.py index 82af869..342463e 100644 --- a/sleekxmpp/features/feature_mechanisms/stanza/challenge.py +++ b/sleekxmpp/features/feature_mechanisms/stanza/challenge.py @@ -33,7 +33,10 @@ class Challenge(StanzaBase): return base64.b64decode(bytes(self.xml.text)) def set_value(self, values): - self.xml.text = bytes(base64.b64encode(values)).decode('utf-8') + if values: + self.xml.text = bytes(base64.b64encode(values)).decode('utf-8') + else: + self.xml.text = '=' def del_value(self): self.xml.text = '' diff --git a/sleekxmpp/features/feature_mechanisms/stanza/response.py b/sleekxmpp/features/feature_mechanisms/stanza/response.py index 45bb820..65f3588 100644 --- a/sleekxmpp/features/feature_mechanisms/stanza/response.py +++ b/sleekxmpp/features/feature_mechanisms/stanza/response.py @@ -33,7 +33,10 @@ class Response(StanzaBase): return base64.b64decode(bytes(self.xml.text)) def set_value(self, values): - self.xml.text = bytes(base64.b64encode(values)).decode('utf-8') + if values: + self.xml.text = bytes(base64.b64encode(values)).decode('utf-8') + else: + self.xml.text = '=' def del_value(self): self.xml.text = ''