mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
A fix for SF bug #472560, extra newlines returned by get_param() when
the separating semi-colon shows up on a continuation line (legal, but weird). Bug reported and fixed by Matthew Cowles. Test case and sample email included.
This commit is contained in:
parent
e674ca737d
commit
2539cf5aad
3 changed files with 51 additions and 1 deletions
|
@ -17,7 +17,7 @@ import Errors
|
||||||
import Utils
|
import Utils
|
||||||
|
|
||||||
SEMISPACE = '; '
|
SEMISPACE = '; '
|
||||||
paramre = re.compile(r';\s*')
|
paramre = re.compile(r'\s*;\s*')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
46
Lib/test/data/msg_22.txt
Normal file
46
Lib/test/data/msg_22.txt
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
Mime-Version: 1.0
|
||||||
|
Message-Id: <a05001902b7f1c33773e9@[134.84.183.138]>
|
||||||
|
Date: Tue, 16 Oct 2001 13:59:25 +0300
|
||||||
|
To: a@example.com
|
||||||
|
From: b@example.com
|
||||||
|
Content-Type: multipart/mixed; boundary="============_-1208892523==_============"
|
||||||
|
|
||||||
|
--============_-1208892523==_============
|
||||||
|
Content-Type: text/plain; charset="us-ascii" ; format="flowed"
|
||||||
|
|
||||||
|
Text text text.
|
||||||
|
--============_-1208892523==_============
|
||||||
|
Content-Id: <a05001902b7f1c33773e9@[134.84.183.138].0.0>
|
||||||
|
Content-Type: image/jpeg; name="wibble.JPG"
|
||||||
|
; x-mac-type="4A504547"
|
||||||
|
; x-mac-creator="474B4F4E"
|
||||||
|
Content-Disposition: attachment; filename="wibble.JPG"
|
||||||
|
Content-Transfer-Encoding: base64
|
||||||
|
|
||||||
|
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
|
||||||
|
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAALCAXABIEBAREA
|
||||||
|
g6bCjjw/pIZSjO6FWFpldjySOmCNrO7DBZibUXhTwtCixw+GtAijVdqxxaPp0aKvmGXa
|
||||||
|
qrbBQvms0mAMeYS/3iTV1dG0hHaRNK01XblnWxtVdjkHLMIgTyqnk9VB7CrP2KzIINpa
|
||||||
|
4O7I+zxYO9WV8jZg71Zlb+8rMDkEirAVQFAUAKAFAAAUAYAUDgADgY6DjpRtXj5RxjHA
|
||||||
|
4wQRj0wQCMdCAewpaKKK/9k=
|
||||||
|
--============_-1208892523==_============
|
||||||
|
Content-Id: <a05001902b7f1c33773e9@[134.84.183.138].0.1>
|
||||||
|
Content-Type: image/jpeg; name="wibble2.JPG"
|
||||||
|
; x-mac-type="4A504547"
|
||||||
|
; x-mac-creator="474B4F4E"
|
||||||
|
Content-Disposition: attachment; filename="wibble2.JPG"
|
||||||
|
Content-Transfer-Encoding: base64
|
||||||
|
|
||||||
|
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
|
||||||
|
AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAALCAXABJ0BAREA
|
||||||
|
/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
|
||||||
|
W6NFJJBEkU10kKGTcWMDwxuU+0JHvk8qAtOpNwqSR0n8c3BlDyXHlqsUltHEiTvdXLxR
|
||||||
|
7vMiGDNJAJWkAMk8ZkCFp5G2oo5W++INrbQtNfTQxJAuXlupz9oS4d5Y1W+E2XlWZJJE
|
||||||
|
Y7LWYQxTLE1zuMbfBPxw8X2fibVdIbSbI6nLZxX635t9TjtYreWR7WGKJTLJFFKSlozO
|
||||||
|
0ShxIXM43uC3/9k=
|
||||||
|
--============_-1208892523==_============
|
||||||
|
Content-Type: text/plain; charset="us-ascii" ; format="flowed"
|
||||||
|
|
||||||
|
Text text text.
|
||||||
|
--============_-1208892523==_============--
|
||||||
|
|
|
@ -218,6 +218,10 @@ class TestMessageAPI(TestEmailBase):
|
||||||
eq(msg.get_param('bar', header='x-header'), 'one')
|
eq(msg.get_param('bar', header='x-header'), 'one')
|
||||||
eq(msg.get_param('baz', header='x-header'), 'two')
|
eq(msg.get_param('baz', header='x-header'), 'two')
|
||||||
|
|
||||||
|
def test_get_param_funky_continuation_lines(self):
|
||||||
|
msg = self._msgobj('msg_22.txt')
|
||||||
|
self.assertEqual(msg.get_payload(1).get_param('name'), 'wibble.JPG')
|
||||||
|
|
||||||
def test_has_key(self):
|
def test_has_key(self):
|
||||||
msg = email.message_from_string('Header: exists')
|
msg = email.message_from_string('Header: exists')
|
||||||
self.failUnless(msg.has_key('header'))
|
self.failUnless(msg.has_key('header'))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue