On 29. feb. 2012, at 08:22, Bill Moseley wrote: > Sorry, this got sent too quickly: > > On Wed, Feb 29, 2012 at 2:15 PM, Bill Moseley <mose...@hank.org> wrote: > >> I have a user-supplied filename that could be anything, including path >> segments and fullset of unicode characters (It's decoded as UTF-8 when >> supplied by the user. >> >> There seems to be quite a bit of debate about what modern browsers will >> except. >> >> my $filename = qq{/some/funny looking/"name that the \\'user' provided' >> with a \x{263A} (smile).doc}; >> >> How can I pass that back in a Content-Disposition "filename" header >> escaped correctly? >> > > > And does $request->header( $name => $value ) > > expect $name and $value to be Character data (decoded into Perl characters) > or does it always need to be encoded first? Seems like the encoding should > happen when the request gets "rendered" for output.
HTTP::Headers doesn't do any encoding for you, which basically means that you need to pass encoded strings as $name and $value, and make sure the result ends up as valid HTTP. RFC 5987 seem to be relevant for HTTP::Headers to support in this regard. This discussion about Content-Disposition seemed relevant to your original question: http://stackoverflow.com/questions/1361604/how-to-encode-utf8-filename-for-http-headers-python-django --Gisle