Commit 97dfad78 authored by R David Murray's avatar R David Murray

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

parent 9833fcbc
...@@ -941,9 +941,7 @@ class MIMEPart(Message): ...@@ -941,9 +941,7 @@ class MIMEPart(Message):
@property @property
def is_attachment(self): def is_attachment(self):
c_d = self.get('content-disposition') c_d = self.get('content-disposition')
if c_d is None: return False if c_d is None else c_d.content_disposition == 'attachment'
return False
return c_d.lower() == 'attachment'
def _find_body(self, part, preferencelist): def _find_body(self, part, preferencelist):
if part.is_attachment: if part.is_attachment:
......
...@@ -729,7 +729,8 @@ class TestEmailMessageBase: ...@@ -729,7 +729,8 @@ class TestEmailMessageBase:
self.assertTrue(m.is_attachment) self.assertTrue(m.is_attachment)
m.replace_header('Content-Disposition', 'AtTachMent') m.replace_header('Content-Disposition', 'AtTachMent')
self.assertTrue(m.is_attachment) self.assertTrue(m.is_attachment)
m.set_param('filename', 'abc.png', 'Content-Disposition')
self.assertTrue(m.is_attachment)
class TestEmailMessage(TestEmailMessageBase, TestEmailBase): class TestEmailMessage(TestEmailMessageBase, TestEmailBase):
......
...@@ -32,6 +32,9 @@ Core and Builtins ...@@ -32,6 +32,9 @@ Core and Builtins
Library 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 #22247: Add NNTPError to nntplib.__all__.
- Issue #4180: The warnings registries are now reset when the filters - Issue #4180: The warnings registries are now reset when the filters
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment