[ python-Bugs-1403349 ] in email can't get attachments' filenames using get_filename

SourceForge.net noreply at sourceforge.net
Tue Jan 17 06:09:39 CET 2006


Bugs item #1403349, was opened at 2006-01-11 16:47
Message generated for change (Comment added) made by bwarsaw
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1403349&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Michal P. (mpasniew)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: in email can't get attachments' filenames using get_filename

Initial Comment:
in the email package (2.4.1) the get_filename() method
returns the MIME field "filename" but some messages
have 'name' field instead, for example:

USUALLY THE HEADER IS:
Content-Type: application/octet-stream;
        name="XX.pdf"
Content-Transfer-Encoding: base64
Content-Description: XX.pdf
Content-Disposition: attachment;
        filename="XX.pdf"

BUT SOMETIMES THE HEADER IS:
Content-type: application/octet-stream; name="XX.xls"
Content-transfer-encoding: base64

For this to work properly I had to code a hack along
these lines:
filename = part.get_filename()
if not filename:
   ct = part.get("Content-type")
   m = re.compile('name=\"(\S+)\"').search(ct, 1)
   if m: filename=m.group(1)

But it would be helpful to code this in the get_filename()

Michal

----------------------------------------------------------------------

>Comment By: Barry A. Warsaw (bwarsaw)
Date: 2006-01-17 00:09

Message:
Logged In: YES 
user_id=12800

r42076 for email 3.0 / python 2.5

r42077 for python 2.4




----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2006-01-16 23:35

Message:
Logged In: YES 
user_id=12800

r42075 for Python 2.3 / email 2.5 (will close after porting
to all other branches).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1403349&group_id=5470


More information about the Python-bugs-list mailing list