[New-bugs-announce] [issue3169] email/header.py doesn't handle Base64 headers that have been insufficiently padded.

Jason Williams report at bugs.python.org
Sun Jun 22 01:58:58 CEST 2008


New submission from Jason Williams <williamsjj at digitar.com>:

email/header.py:decode_header() Line 95: dec = 
email.base64mime.decode(encoded)

Headers that contain Subject or From headers which are Base64 encoded 
and are insufficiently padded raise a HeaderParseError. The actual 
padding error is begin generated in binascii.a2b_base64 and bubbling up 
as a HeaderParseError in header.py. 

decode_header() should detect the padding error (Base64 text length does 
not evenly divide by 3) and automatically add padding before handing off 
to a2b_base64. The problem usually occurs with spam.

Example problem header:
Subject: =?iso-8859-1?B?
UHJldmVudCBGb3JlY2xvc3VyZSAmIFNhdmUgWW91ciBIb21lIA=?=


Properly Padded:
Subject: =?iso-8859-1?B?
UHJldmVudCBGb3JlY2xvc3VyZSAmIFNhdmUgWW91ciBIb21lIA==?=

----------
components: Library (Lib)
messages: 68553
nosy: jasonjwwilliams
severity: normal
status: open
title: email/header.py doesn't handle Base64 headers that have been insufficiently padded.
type: behavior
versions: Python 2.5

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


More information about the New-bugs-announce mailing list