New submission from Sérgio Surkamp <[email protected]>:
There is bug in PLAIN mechanism's of smtplib. The generated base64 string fail
when the password start with numbers. As long as I could find, the error occur
in method encode_plain. Using the null character (\0) in hexadecimal
representation (\x00) seems to fix the problem.
Origin of the problem:
def encode_plain(user, password):
return encode_base64("\0%s\0%s" % (user, password), eol="")
Proposed fix:
def encode_plain(user, password):
return encode_base64("\x00%s\x00%s" % (user, password), eol="")
Current result:
>>> from email.base64mime import encode as encode_base64
>>> import base64
>>> encode_base64("\0user\0123foo", eol="")
'AHVzZXIKM2Zvbw=='
>>> f = base64.decodestring('AHVzZXIKM2Zvbw==')
>>> f
'\x00user\n3foo'
Expected result:
>>> from email.base64mime import encode as encode_base64
>>> import base64
>>> encode_base64("\x00user\x00123foo", eol="")
'AHVzZXIAMTIzZm9v'
>>> f = base64.decodestring('AHVzZXIAMTIzZm9v')
>>> f
'\x00user\x00123foo'
----------
components: Extension Modules
messages: 98295
nosy: surkamp
severity: normal
status: open
title: smtplib SASL PLAIN authentication error
versions: Python 2.5, Python 2.6
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue7779>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com