2

I'm trying to deliver a file to the browser that can have non-ASCII characters in the file name and I've been playing around with using the Content-Disposition header to tell the browser about the desired file name to use when the user wants to save the file.

I've looked at RFC 6266 where I saw the use of filename*. So, as a test, I set the following header in a Java servlet (where resp is a HttpServletResponse):

resp.setHeader("Content-Disposition", "inline; filename=test.png; filename*=utf-8''test%20x.png");

It seems that all "modern" browsers understand this now and support filename* and also prefer it over the value set for filename. I've tried it with Arabic characters and they worked fine in the latest Chrome and Firefox versions and in IE11. But: unlike the other browsers IE does not seem to understand the %20 here. When I try to save the file it has the file name as test%20x.png instead of test x.png.

Has anyone encountered this before? Is it an IE bug? And if so, are there workarounds? (I could just replace the space with an underscore but maybe I don't have to.)

Maybe I'm doing something wrong with the encoding or maybe it's to do with the Java Servlet environment. (I doubt it but I tagged the question as a Java Servlet one anyway in case it is.) I can provide more details about how the file is delivered by the servlet if necessary but maybe someone has seen this with IE in a different environment as well.

Community
  • 1
  • 1
Shepard
  • 195
  • 2
  • 7
  • this looks relevant to your issue http://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http – securecodeninja Mar 23 '15 at 17:35
  • @Roman: Yeah, I looked at that before but it didn't help. :-/ Thanks anyway! – Shepard Mar 25 '15 at 10:34

0 Answers0