Open Bug 381936 Opened 17 years ago Updated 2 months ago

Content-Disposition filename not obeyed when choosing to "Open" a file whose extension doesn't match Content-Type

Categories

(Firefox :: File Handling, defect)

x86
Windows XP
defect

Tracking

()

People

(Reporter: nen, Unassigned)

Details

Attachments

(1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11

When clicking on a link that returns "Content-Disposition: attachment; filename=", and the extension of the filename doesn't follow Content-Type, Firefox adds a new extension when the link is chosen to open with a Helper Application.

"Save as" correctly obeys the given filename, the problem only occurs with "Open with". Also, this happens only on Windows, not on Linux or Mac versions.

Reproducible: Always

Steps to Reproduce:
1. Access a website that returns a file.eml with Content-Type: text/plain (such as in the Additional Information)
2. Choose to "Open with" an application that shows the filename
Actual Results:  
File is saved to temp as .eml.txt and opened in the chosen application

Expected Results:  
File shoud be saved to temp as .eml and opened in the chosen application

<?php
header('Content-Disposition: attachment; filename="test.eml"');
header('Content-Type: text/plain');
//header('Content-Type: message/rfc822');
?>
message content
I believe this is intentional, see http://lxr.mozilla.org/seamonkey/source/uriloader/exthandler/nsExternalHelperAppService.cpp#1579 for why.
Product: Firefox → Core
QA Contact: file.handling → file-handling
Summary: Content-Disposition filename not obeyed when its extension doesn't follow Content-Type → Content-Disposition filename not obeyed when choosing to "Open" a file whose extension doesn't match Content-Type
I appreciate the security features, they are useful for people who use the default handler for downloaded files without much thought into the information displayed about the file.

When however a user specifically chooses another handler after having seen the original filename and content type, I think it's safe to say that they know what they're doing, and their choice should be respected without doing something unexpected such as a file rename.
In firefox, the filename changes from test.xml to test.xml.xls
In IE8, the filename is changed from test.xml to test.xls

The problem is: if the server sends for example an excel table in XML format,
and the filename is changed to .xls, excel complains about a mismatch between the file extension and the file contents.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Product: Core → Firefox
Severity: normal → S3
Attachment #9386964 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: