Filenames with spaces are truncated upon download

From MozillaZine Knowledge Base
Jump to navigationJump to search

When downloading certain files, you may find that the filename is truncated up to the first space. Thus, a link to download the file "My Report.doc" produces a save dialog containing "My" as the filename. This is a case of the website incorrectly sending the filename, and the browser coping as best it can. Yahoo! Mail is one major site with this bug (though the next version of the service has reportedly fixed the bug).


If the browser is set to ask where to save files, the user can choose any file name. ([Options menu] > Main > Downloads. Check "Ask me where to save files".) The extension TruncFix is another way to fix this problem. You should also inform the webmaster of the site in question, so the problem can be fixed.

Detailed Explanation

To force a browser to produce a "Save As..." dialog for a given URL, a web server may send it using a Content-Disposition: attachment header. Using our earlier example of "My Report.doc", the webserver should send these HTTP headers to adhere to the specification and be compatible with all browsers:

Content-Type: application/msword
Content-Disposition: attachment; filename="My Report.doc"

Note that the filename is surrounded by double quotes, per RFC 2231. This allows for the use of extended characters within the filename (i.e., international characters, though at present Internet Explorer does not support this internationalization).

An unfortunately large number of web servers instead do not include the enclosing quotes around the filename:

Content-Type: application/msword
Content-Disposition: attachment; filename=My Report.doc

This creates an ambiguity when parsing the header for the filename when the browser has to consider the possibility of internationalized filenames. As Internet Explorer does not have to worry about this, it will parse the filename until the end of the line. Mozilla will not.

There are no plans to change this behavior.

External Links