File tree 4 files changed +53
-7
lines changed
4 files changed +53
-7
lines changed Original file line number Diff line number Diff line change 1
- # Copyright (C) 2001-2005 Python Software Foundation
1
+ # Copyright (C) 2001-2006 Python Software Foundation
2
2
# Author: barry@python.org (Barry Warsaw)
3
3
4
4
"""Basic message object for the email package object model."""
@@ -718,10 +718,15 @@ def get_filename(self, failobj=None):
718
718
"""Return the filename associated with the payload if present.
719
719
720
720
The filename is extracted from the Content-Disposition header's
721
- `filename' parameter, and it is unquoted.
721
+ `filename' parameter, and it is unquoted. If that header is missing
722
+ the `filename' parameter, this method falls back to looking for the
723
+ `name' parameter.
722
724
"""
723
725
missing = []
724
726
filename = self .get_param ('filename' , missing , 'content-disposition' )
727
+ if filename is missing :
728
+ # Some MUAs use a different parameter name
729
+ filename = self .get_param ('name' , missing , 'content-disposition' )
725
730
if filename is missing :
726
731
return failobj
727
732
if isinstance (filename , TupleType ):
Original file line number Diff line number Diff line change 1
- # Copyright (C) 2001-2005 Python Software Foundation
1
+ # Copyright (C) 2001-2006 Python Software Foundation
2
2
# Author: barry@python.org (Barry Warsaw)
3
3
4
- """A package for parsing, handling, and generating email messages.
5
- """
4
+ """A package for parsing, handling, and generating email messages."""
6
5
7
- __version__ = '2.5.6 '
6
+ __version__ = '2.5.7 '
8
7
9
8
__all__ = [
10
9
'base64MIME' ,
Original file line number Diff line number Diff line change
1
+ Return-Path: <barry@python.org>
2
+ Delivered-To: barry@python.org
3
+ Received: by mail.python.org (Postfix, from userid 889)
4
+ id C2BF0D37C6; Tue, 11 Sep 2001 00:05:05 -0400 (EDT)
5
+ MIME-Version: 1.0
6
+ Content-Type: multipart/mixed; boundary="h90VIIIKmx"
7
+ Content-Transfer-Encoding: 7bit
8
+ Message-ID: <15261.36209.358846.118674@anthem.python.org>
9
+ From: barry@python.org (Barry A. Warsaw)
10
+ To: barry@python.org
11
+ Subject: a simple multipart
12
+ Date: Tue, 11 Sep 2001 00:05:05 -0400
13
+ X-Mailer: VM 6.95 under 21.4 (patch 4) "Artificial Intelligence" XEmacs Lucid
14
+ X-Attribution: BAW
15
+ X-Oblique-Strategy: Make a door into a window
16
+
17
+
18
+ --h90VIIIKmx
19
+ Content-Type: text/plain
20
+ Content-Disposition: inline; name="msg.txt"
21
+ Content-Transfer-Encoding: 7bit
22
+
23
+ a simple kind of mirror
24
+ to reflect upon our own
25
+
26
+ --h90VIIIKmx
27
+ Content-Type: text/plain
28
+ Content-Disposition: inline; name="msg.txt"
29
+ Content-Transfer-Encoding: 7bit
30
+
31
+ a simple kind of mirror
32
+ to reflect upon our own
33
+
34
+ --h90VIIIKmx--
35
+
Original file line number Diff line number Diff line change 1
- # Copyright (C) 2001-2005 Python Software Foundation
1
+ # Copyright (C) 2001-2006 Python Software Foundation
2
2
# email package unit tests
3
3
4
4
import os
@@ -158,6 +158,13 @@ def test_get_filename(self):
158
158
subpart = msg .get_payload (1 )
159
159
eq (subpart .get_filename (), 'dingusfish.gif' )
160
160
161
+ def test_get_filename_with_name_parameter (self ):
162
+ eq = self .assertEqual
163
+
164
+ msg = self ._msgobj ('msg_41.txt' )
165
+ filenames = [p .get_filename () for p in msg .get_payload ()]
166
+ eq (filenames , ['msg.txt' , 'msg.txt' ])
167
+
161
168
def test_get_boundary (self ):
162
169
eq = self .assertEqual
163
170
msg = self ._msgobj ('msg_07.txt' )
You can’t perform that action at this time.
0 commit comments