This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mpasniew
Recipients
Date 2006-01-11.21:47:23
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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
History
Date User Action Args
2007-08-23 14:37:15adminlinkissue1403349 messages
2007-08-23 14:37:15admincreate