Fix for issue 5259: ASCII encode the username and password before passing

it to encode_base64, which requires bytes in py3k.  Fix by Musashi Tamura,
tests by Marcin Bachry.
This commit is contained in:
R. David Murray 2009-05-23 18:49:56 +00:00
parent dfea192ad4
commit caa27b7823
4 changed files with 26 additions and 1 deletions

View file

@ -545,7 +545,8 @@ class SMTP:
return encode_base64(response)
def encode_plain(user, password):
return encode_base64("\0%s\0%s" % (user, password))
s = "\0%s\0%s" % (user, password)
return encode_base64(s.encode('ascii'), eol='')
AUTH_PLAIN = "PLAIN"