mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
Ported 42075 from release23-maint branch.
SF bug #1403349 solution for email 3.0; some MUAs use the 'file' parameter name in the Content-Distribution header, so Message.get_filename() should fall back to using that. Will port to the Python 2.5 trunk. Also, bump the email package version to 3.0.1 for eventual release. Of course, add a test case too. XXX Need to update the documentation.
This commit is contained in:
parent
989b69a519
commit
a0f28efcd1
4 changed files with 51 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2001-2004 Python Software Foundation
|
||||
# Copyright (C) 2001-2006 Python Software Foundation
|
||||
# Author: Barry Warsaw
|
||||
# Contact: email-sig@python.org
|
||||
|
||||
|
@ -701,10 +701,14 @@ class Message:
|
|||
"""Return the filename associated with the payload if present.
|
||||
|
||||
The filename is extracted from the Content-Disposition header's
|
||||
`filename' parameter, and it is unquoted.
|
||||
`filename' parameter, and it is unquoted. If that header is missing
|
||||
the `filename' parameter, this method falls back to looking for the
|
||||
`name' parameter.
|
||||
"""
|
||||
missing = object()
|
||||
filename = self.get_param('filename', missing, 'content-disposition')
|
||||
if filename is missing:
|
||||
filename = self.get_param('name', missing, 'content-disposition')
|
||||
if filename is missing:
|
||||
return failobj
|
||||
return Utils.collapse_rfc2231_value(filename).strip()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue