Use '=' as base64 value for empty string SASL results.

This commit is contained in:
Lance Stout 2012-02-09 22:01:11 -08:00
parent ca5145c210
commit c1357717d9
3 changed files with 12 additions and 3 deletions

View file

@ -41,7 +41,10 @@ class Auth(StanzaBase):
def set_value(self, values): def set_value(self, values):
if not self['mechanism'] in self.plain_mechs: 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: else:
self.xml.text = bytes(values).decode('utf-8') self.xml.text = bytes(values).decode('utf-8')

View file

@ -33,7 +33,10 @@ class Challenge(StanzaBase):
return base64.b64decode(bytes(self.xml.text)) return base64.b64decode(bytes(self.xml.text))
def set_value(self, values): 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): def del_value(self):
self.xml.text = '' self.xml.text = ''

View file

@ -33,7 +33,10 @@ class Response(StanzaBase):
return base64.b64decode(bytes(self.xml.text)) return base64.b64decode(bytes(self.xml.text))
def set_value(self, values): 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): def del_value(self):
self.xml.text = '' self.xml.text = ''