Firefox – Disable “open with” option on Firefox downloads (force Firefox to always save all files)

downloadfirefoxmime-types

The symptoms

  • Users open their web mail accounts, click on some attachment, and click "Open with Word".
  • Users edit their precious documents for hours. Users save word doc and exit.
  • Users can't find file.
  • Users grab torches and pitchforks (last step optional).

enter image description here

The cause of the problem

The download dialog for Firefox shows two options: "Save file" and "Open with".

enter image description here

By choosing "open with", Firefox downloads the file to a temp folder and opens the associated application. I want to prevent this behavior.

What I tried

I made my homework and searched the MozillaZine, and the Knowledge Base (like here, here or here) and if I understood correctly, the download dialog box will depend not on the file's extension, but rather on its mime type.

I know I can set the behavior by going to Preferences > Applications, like this:

enter image description here

However:

  • Firefox relies on the mime type informed by the server. But it can be itself incorrect, omitted, or redundant (one file type can have multiple mime types, or vice-versa).
  • Firefox remembers the "Do this automatically for files like this from now on" check-box on a per-mimetype basis. If I want to enforce a certain behavior, I have to manually set it for each mime type.
  • I can not create new entries in the applications list. It is populated only when a new download is made from an unregistered mime type. Only then I can change the behavior in the list.
  • I can edit the mimetypes.rdf file, forcing the "save file" behavior, but I couldn't find a way to enforce this to all files.

What I need is a way to (preferably) make it impossible to open with an external application, or at least to force the file to be saved.

I know I can set browser.altClickSave in about:config to have it save the file when I click pressing ALT, but I need some solution that does not require user interaction.

Best Answer

Making a master mimeTypes.rdf file that you deploy to users is the best solution

Open mimeTypes.rdf in an editor that handles XML style docs well (such as Notepad++)

Find and replace first line with second:

NC:saveToDisk="false"
NC:saveToDisk="true"
  and
NC:alwaysAsk="true"
NC:alwaysAsk="false"  

I would also "seed" your master mimeTypes.rdf with some of the exotics your users have accumulated:

  1. Copy mimeTypes.rdf from the 2-3 users with the heaviest usage of webmail attachments
  2. Compare users' types to your master:

cmd.exe

find "<RDF:li RDF:resource=" Master_mimeTypes.rdf > MasterMimes.txt   #generate list of mimetypes
find "<RDF:li RDF:resource=" User1_mimeTypes.rdf > User1Mimes.txt     #generate list of mimetypes
fc MasterMimes.txt User1Mimes.txt                                     #compare lists of mimetypes

If you find any new types, grab the whole stanza from the user's file and add to master.