Fix saslprep on the username
Two issues fixed here: - ints are not comparable with bytes, so char was never == to b',', which renders the whole function pointless - The bytes were converted back to “characters” by using chr(), which doesn’t make sense if the username contains characters that fit on more than one bytes. This would trigger an “invalid username” error from the server when using a non-ascii JID.
This commit is contained in:
parent
aabec8b993
commit
f5ae98aaf1
@ -223,17 +223,16 @@ class SCRAM(Mech):
|
|||||||
return self.hash(text).digest()
|
return self.hash(text).digest()
|
||||||
|
|
||||||
def saslname(self, value):
|
def saslname(self, value):
|
||||||
escaped = b''
|
value = value.decode("utf-8")
|
||||||
for char in bytes(value):
|
escaped = []
|
||||||
if char == b',':
|
for char in value:
|
||||||
escaped += b'=2C'
|
if char == ',':
|
||||||
elif char == b'=':
|
escaped += '=2C'
|
||||||
escaped += b'=3D'
|
elif char == '=':
|
||||||
|
escaped += '=3D'
|
||||||
else:
|
else:
|
||||||
if isinstance(char, int):
|
escaped += char
|
||||||
char = chr(char)
|
return "".join(escaped).encode("utf-8")
|
||||||
escaped += bytes(char)
|
|
||||||
return escaped
|
|
||||||
|
|
||||||
def parse(self, challenge):
|
def parse(self, challenge):
|
||||||
items = {}
|
items = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user