email.get_filename() with newline

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Nov 12 03:46:59 EST 2007


En Fri, 09 Nov 2007 10:46:15 -0300, Thomas Guettler <hv at tbz-pariv.de>  
escribi�:

> if I use part.get_filename() with the following email part:
>
> ------_=_NextPart_001_01C81B11.52AB8006
> Content-Type: application/vnd.ms-excel;
> 	name="=?iso-8859-1?Q?30102007=28aktualisiert=29=5FK=FCndigungen_enviaM=5FErdgas?=
> 	=?iso-8859-1?Q?_S=FCds__GmbH=2Exls?="
> Content-Disposition: attachment;
> 	filename="=?iso-8859-1?Q?30102007=28aktualisiert=29=5FK=FCndigungen_enviaM=5FErdgas?=
> 	=?iso-8859-1?Q?_S=FCds__GmbH=2Exls?="
> Content-Description:  
> =?iso-8859-1?Q?30102007=28aktualisiert=29=5FK=FCndigungen_enviaM=5FErdgas?=
> 	=?iso-8859-1?Q?_S=FCds__GmbH=2Exls?=
> Content-Transfer-Encoding: base64
>
> 0M8R4KGxGu...
>
> I get a filename which includes a newline character and the ?iso...  
> encoding
> is not resolved. But the mail user agent "mutt" does display the filename
> correct. I tried it with the latest email packages (4.0.2).

According to RFC2047, section 5:

    + An 'encoded-word' MUST NOT appear within a 'quoted-string'.

    + An 'encoded-word' MUST NOT be used in parameter of a MIME
      Content-Type or Content-Disposition field, or in any structured
      field body except within a 'comment' or 'phrase'.

so the above headers are invalid.

> Any hints how to parse this filename?

You may try joining the lines and unfolding them by hand, and perhaps then  
you could convince the decode_header function to work in this case...

-- 
Gabriel Genellina




More information about the Python-list mailing list