]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bdecode was already gone in email 5. This merge adds the test from
authorR. David Murray <rdmurray@bitdance.com>
Mon, 8 Mar 2010 02:17:03 +0000 (02:17 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Mon, 8 Mar 2010 02:17:03 +0000 (02:17 +0000)
the trunk patch, and removes the last trace of bdecode, which was
a commented out call in message.py.

Merged revisions 78778 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78778 | r.david.murray | 2010-03-07 21:04:06 -0500 (Sun, 07 Mar 2010) | 9 lines

  Issue #7143: get_payload used to strip any trailing newline from a
  base64 transfer-encoded payload *after* decoding it; it no longer does.
  email had a special method in utils, _bdecode, specifically to do this,
  so it must have served a purpose at some point, yet it is clearly wrong
  per RFC.  Fixed with Barry's approval, but no backport.  Email package
  minor version number is bumped, now version 4.0.1.

  Patch by Joaquin Cuenca Abela.
........

Lib/email/message.py
Lib/email/test/data/msg_10.txt
Lib/email/test/test_email.py
Misc/ACKS

index d89e37e0b6178771d2d5a2f6bcaafc0b185bffe0..3608d1a959788eedf3c73c43d3beccf0415bed33 100644 (file)
@@ -204,7 +204,6 @@ class Message:
                 if isinstance(payload, str):
                     payload = payload.encode('raw-unicode-escape')
                 return base64.b64decode(payload)
-                #return utils._bdecode(payload)
             except binascii.Error:
                 # Incorrect padding
                 pass
index bd30d13ad1ae3c40ad84ac3ef958d802458880e1..07903960f9fe0de865ab7a7dfaa9264e2d6cd739 100644 (file)
@@ -24,6 +24,13 @@ Content-Transfer-Encoding: Base64
 VGhpcyBpcyBhIEJhc2U2NCBlbmNvZGVkIG1lc3NhZ2Uu
 
 
+--BOUNDARY
+Content-Type: text/plain; charset="iso-8859-1"
+Content-Transfer-Encoding: Base64
+
+VGhpcyBpcyBhIEJhc2U2NCBlbmNvZGVkIG1lc3NhZ2UuCg==
+
+
 --BOUNDARY
 Content-Type: text/plain; charset="iso-8859-1"
 
index 27ddc7c58aa3839edb89fa31fe7782c74d2481ef..5e4d9ba149f66cab0557b82849bcc72ae9068727 100644 (file)
@@ -204,8 +204,12 @@ class TestMessageAPI(TestEmailBase):
         # Subpart 3 is base64
         eq(msg.get_payload(2).get_payload(decode=True),
            b'This is a Base64 encoded message.')
-        # Subpart 4 has no Content-Transfer-Encoding: header.
+        # Subpart 4 is base64 with a trailing newline, which
+        # used to be stripped (issue 7143).
         eq(msg.get_payload(3).get_payload(decode=True),
+           b'This is a Base64 encoded message.\n')
+        # Subpart 5 has no Content-Transfer-Encoding: header.
+        eq(msg.get_payload(4).get_payload(decode=True),
            b'This has no Content-Transfer-Encoding: header.\n')
 
     def test_get_decoded_uu_payload(self):
index 8342bf94fafeb9ddf09ab9a2435d79597884418e..ec15267d240842f6c7da6e00de494ad2cb91f9a7 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -9,6 +9,7 @@ Without you, I would've stopped working on Python long ago!
 
 PS: In the standard Python distribution, this file is encoded in UTF-8.
 
+Joaquin Cuenca Abela
 David Abrahams
 Jim Ahlstrom
 Farhan Ahmad