mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
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. ........
This commit is contained in:
parent
f38d888f2f
commit
75a292e5be
5 changed files with 18 additions and 2 deletions
|
|
@ -1611,6 +1611,15 @@ class TestRFC2047(unittest.TestCase):
|
|||
('rg', None), ('\xe5', 'iso-8859-1'),
|
||||
('sbord', None)])
|
||||
|
||||
def test_rfc2047_B_bad_padding(self):
|
||||
s = '=?iso-8859-1?B?%s?='
|
||||
data = [ # only test complete bytes
|
||||
('dm==', 'v'), ('dm=', 'v'), ('dm', 'v'),
|
||||
('dmk=', 'vi'), ('dmk', 'vi')
|
||||
]
|
||||
for q, a in data:
|
||||
dh = decode_header(s % q)
|
||||
self.assertEqual(dh, [(a, 'iso-8859-1')])
|
||||
|
||||
|
||||
# Test the MIMEMessage class
|
||||
|
|
@ -3064,7 +3073,7 @@ A very long line that must get split to something other than at the
|
|||
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue