Subject: | MIME::Head->recommended_filename returns empty result on some malformed headers |
Date: | Mon, 22 Jul 2013 09:52:45 +0200 |
To: | bug-MIME-tools [...] rt.cpan.org |
From: | Christian Loos <cloos [...] netcologne.de> |
Hi,
attached an file with 5 headers from file attachments where
MIME::Head->recommended_filename returns an empty result.
As far as I can see the headers are not correct quoted and encoded, so
this is not your fault. But maybe there is an chance to get an
workaround to help applications that use MIME::tools (in my case RT) to
get the correct filename.
In the first three header examples content-disposition.filename and
content-type.name are enclosed by repeated double quotes and
MIME::Field::ParamVal->parse failes to parse them.
The content-description header has the correct filename and the correct
quoting.
In the fourth and fifth header example content-disposition.filename and
content-type.name are empty.
But as you see the content-description header has the correct filename
and the correct quoting.
As an workaround, if MIME::Head->recommended_filename fails, I parse the
filename from the content-descrition header with
MIME::Head->get('Content-Disposition').
RFC 2045
8. Content-Description Header Field
The ability to associate some descriptive information with a given
body is often desirable. For example, it may be useful to mark an
"image" body as "a picture of the Space Shuttle Endeavor." Such text
may be placed in the Content-Description header field. This header
field is always optional.
description := "Content-Description" ":" *text
The description is presumed to be given in the US-ASCII character
set, although the mechanism specified in RFC 2047 may be used for
non-US-ASCII Content-Description values.
Maybe it would be an option, if parsing content-disposition.filename and
content-type.name fails, to parse the content-descrition header instead
of returning an empty recommended_filename.
The problematic header examples comes from an mail generated with MS
Outlook (2007 or 2010) and all have German umlauts and comma in the
filename.
Thanks.
Chris
Message body is not shown because sender requested not to inline it.