From e06528c64b62abbaa49dedc395e1ce58ad3962fe Mon Sep 17 00:00:00 2001 From: "R. David Murray" Date: Tue, 3 Aug 2010 23:35:44 +0000 Subject: Merged revisions 83690 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83690 | r.david.murray | 2010-08-03 18:14:10 -0400 (Tue, 03 Aug 2010) | 10 lines #3196: if needed pad a short base64 encoded word before trying to decode. The RFCs encourage following Postel's law: be liberal in what you accept. So if someone forgot to pad the base64 encoded word payload to an even four bytes, we add the padding before handing it to base64mime.decode. Previously, missing padding resulted in a HeaderParseError. Patch by Jason Williams. ........ --- Lib/email/header.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Lib/email/header.py') diff --git a/Lib/email/header.py b/Lib/email/header.py index 3215a80f9b..afcea40458 100644 --- a/Lib/email/header.py +++ b/Lib/email/header.py @@ -94,6 +94,9 @@ def decode_header(header): word = email.quoprimime.header_decode(encoded_string) decoded_words.append((word, charset)) elif encoding == 'b': + paderr = len(encoded_string) % 4 # Postel's law: add missing padding + if paderr: + encoded_string += '==='[:4 - paderr] try: word = email.base64mime.decode(encoded_string) except binascii.Error: -- cgit v1.2.1