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:
(b'rg', None), (b'\xe5', 'iso-8859-1'),
(b'sbord', None)])
+ def test_rfc2047_B_bad_padding(self):
+ s = '=?iso-8859-1?B?%s?='
+ data = [ # only test complete bytes
+ ('dm==', b'v'), ('dm=', b'v'), ('dm', b'v'),
+ ('dmk=', b'vi'), ('dmk', b'vi')
+ ]
+ for q, a in data:
+ dh = decode_header(s % q)
+ self.assertEqual(dh, [(a, 'iso-8859-1')])
\f
# Test the MIMEMessage class
def test_broken_base64_header(self):
raises = self.assertRaises
- s = 'Subject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3IQ?='
+ s = 'Subject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?='
raises(errors.HeaderParseError, decode_header, s)
Library
-------
+- Issue #3196: email header decoding is now forgiving if an RFC2047
+ encoded word encoded in base64 is lacking padding.
+
- Issue #8447: Make distutils.sysconfig follow symlinks in the path to
the interpreter executable. This fixes a failure of test_httpservers
on OS X.