#21079: is_attachment now looks only at the value, ignoring parameters.

This commit is contained in:
R David Murray 2014-09-20 17:44:53 -04:00
parent 9833fcbca3
commit 97dfad7856
3 changed files with 6 additions and 4 deletions

View file

@ -941,9 +941,7 @@ def __init__(self, policy=None):
@property
def is_attachment(self):
c_d = self.get('content-disposition')
if c_d is None:
return False
return c_d.lower() == 'attachment'
return False if c_d is None else c_d.content_disposition == 'attachment'
def _find_body(self, part, preferencelist):
if part.is_attachment:

View file

@ -729,7 +729,8 @@ def test_is_attachment(self):
self.assertTrue(m.is_attachment)
m.replace_header('Content-Disposition', 'AtTachMent')
self.assertTrue(m.is_attachment)
m.set_param('filename', 'abc.png', 'Content-Disposition')
self.assertTrue(m.is_attachment)
class TestEmailMessage(TestEmailMessageBase, TestEmailBase):

View file

@ -32,6 +32,9 @@ Core and Builtins
Library
-------
- Issue #21079: Fix email.message.EmailMessage.is_attachment to return the
correct result when the header has parameters as well as a value.
- Issue #22247: Add NNTPError to nntplib.__all__.
- Issue #4180: The warnings registries are now reset when the filters