Wrong filename when doing "save link as" in Firefox
| Project: | Attachment |
| Version: | HEAD |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Jump to:
Sorry if this makes a duplicate comment. If so, please feel free to delete/move this post.
As mentioned in #74983, Firefox has a rather disturbing behaviour for a while now concering dynamic URL.
Let's assume you havefile attachments pointing to some dynamic URL (http://www.example.com/filemanager/active?fid=65). Now right click on it with Firefox, and select "save link as". A dialog box pops up with a default filename : "active.html", which can be rather confusing for normal users.
The underlying mechanism is this. File attachments can be served in two ways, depending on the Content-Disposition header sent by the server :
- inline : IE or Firefox then tries to render the file in the browser window (through plugins or whatever)
- attachment : IE or Firefox opens a dialog box offering the user to save the file on disk. Th default filename is correct because it is transmitted by the server in the Content-Disposition header.
So if you wish your users to be able to display attachments in the browser, you have to send a "Content-Disposition : inline" header.
Here comes the problem : if a user then wishes to save the file on disk instead of viewing it online, he generally right clicks the link and select "save link as...".
- IE then sends an HTTP request to the server, looks at the response, extract the suggested filename from the headers (Content-Disposition), and pops up a save dialog box with the correct filename
- Firefox developpers don't want the user to wait for the server response before displaying the dialog box, so it guesses the filename from the URL and pops up a dialog box with the guessed filename, which generally then have a wrong extension (and/or filename)... For the above example, whatever the file type (video, pdf, ...), the default filename will always be "active.html". Firefox developpers seem to want it to behave this way.
Here are some ways to present file attachements to the user in a more friendly way :
- don't use dynamic URL. Just use URLs from which Firefox guesses a correct filename. For example : http://www.example.com/system/files/myfile.pdf
- present the user with two links : one sending the file inline, the other one as attachment
The enclosed patch is a suggestion on how to implement the second solution. It relied on filemanager module's flexibility to send custom headers, depending on the URL aked for. In the file attachment table, you now have two links, one which sends the file inline, another one ("Download") which sends it as attachment so that the user can save it to disk.
Hope this helps...
| Attachment | Size |
|---|---|
| attachment_4.patch | 1.96 KB |

#1
changing status.
#2
Just so that others may reproduce this issue, it only appears when clean URLs are enabled and attachment security settings are set to "private". Is that correct?