[issue7143] get_payload(decode=True) eats last newline in base64 encoded payload

Joaquin Cuenca Abela report at bugs.python.org
Thu Mar 4 17:03:47 CET 2010


Joaquin Cuenca Abela <e98cuenc at gmail.com> added the comment:

Hi,

I've never before made a patch to Python, so take it with care.

A couple of comments, I reused a test where all the attachments contained an ending newline, except for the base64 one (conveniently...)

I think the comment in _bdecode that Andreas quoted before refers to base64.encodestring add an extra \n to de encoded string, but base64.decodestring can work with and without this extra \n:

>>> import base64
>>> base64.decodestring('MTIzCg==')
'123\n'
>>> base64.decodestring('MTIzCg==\n')
'123\n'

So it's not necessary to work around this in _bdecode. Let me know if it looks good to you.

----------
keywords: +patch
Added file: http://bugs.python.org/file16433/b64crlf.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7143>
_______________________________________


More information about the Python-bugs-list mailing list