This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author surkamp
Recipients surkamp
Date 2010-01-25.20:52:56
SpamBayes Score 1.7566475e-05
Marked as misclassified No
Message-id <1264452779.18.0.958137638395.issue7779@psf.upfronthosting.co.za>
In-reply-to
Content
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'
History
Date User Action Args
2010-01-25 20:52:59surkampsetrecipients: + surkamp
2010-01-25 20:52:59surkampsetmessageid: <1264452779.18.0.958137638395.issue7779@psf.upfronthosting.co.za>
2010-01-25 20:52:57surkamplinkissue7779 messages
2010-01-25 20:52:56surkampcreate