]> granicus.if.org Git - python/commitdiff
#21079: is_attachment now looks only at the value, ignoring parameters.
authorR David Murray <rdmurray@bitdance.com>
Sat, 20 Sep 2014 21:44:53 +0000 (17:44 -0400)
committerR David Murray <rdmurray@bitdance.com>
Sat, 20 Sep 2014 21:44:53 +0000 (17:44 -0400)
Lib/email/message.py
Lib/test/test_email/test_message.py
Misc/NEWS

index aa46debeba51ad8802b3a04eee400261e1eac8ef..124071d5e1d189c2796ecff77da5f8354a9c2eef 100644 (file)
@@ -941,9 +941,7 @@ class MIMEPart(Message):
     @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:
index c761c62d04a0b8d62f2e53887c951a1f5909b9ab..51ddf360996b18a96b3fff63ff27df8575a35a93 100644 (file)
@@ -729,7 +729,8 @@ class TestEmailMessageBase:
         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):
index 1ba6a4ac6525514ebe36c742bb26eeb7d3edbb58..c5afa50c83722a891612c4f013a9cbb3c88334d3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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