Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

ابحث في الدعم

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

On the circumvention of forced downloading instead of opening

  • 4 ردود
  • 1 has this problem
  • 2 views
  • آخر ردّ كتبه VicSter

more options

The date is 2023/08/22 and I am on Windows 10, using Firefox 116.0.2 (64-bit).

I am observing a specific behavior where by certain files, often files which Firefox is well equipped to render, such as Plain Text files, jpegs, and other image formats, are being force-downloaded when clicked on, or when their link is pasted into a new tab. The proof that Firefox is able to display these files is ascertained by way of setting Windows file associations to Firefox itself, and turning off automatic downloads within Firefox, which presents the user with an Open or Save dialog. However, selecting Open does indeed obey the Windows prerogative declared in the file association index, however, the file was still downloaded as an entirely superfluous action, and and then opened by Firefox, from the default "download" directory. This behavior can be repeated in some instances even with images, when right clicking on the image, and selecting "open in new tab", where by the image will be downloaded by that new tab instead of being rendered.

What is the proper methodology to navigate the problem space of this unwanted behavior? The success condition would be Firefox not downloading the file at all and opening it like it is able to do in other instances.

PS: I realize all content is actually downloaded anyway, otherwise it wouldn't be possible to render it. However, this is done in the defined cache folder. I would like this behavior to extend to all files. Excluding, of course, executable binaries, as I understand that design decision is made for security reasons and to allow malware scanners to function properly.

Thank you in advance.

The date is 2023/08/22 and I am on Windows 10, using Firefox 116.0.2 (64-bit). I am observing a specific behavior where by certain files, often files which Firefox is well equipped to render, such as Plain Text files, jpegs, and other image formats, are being force-downloaded when clicked on, or when their link is pasted into a new tab. The proof that Firefox is able to display these files is ascertained by way of setting Windows file associations to Firefox itself, and turning off automatic downloads within Firefox, which presents the user with an Open or Save dialog. However, selecting Open does indeed obey the Windows prerogative declared in the file association index, however, ''the file was still downloaded'' as an entirely superfluous action, and ''and then'' opened by Firefox, from the default "download" directory. This behavior can be repeated in some instances even with images, when right clicking on the image, and selecting "open in new tab", where by the image will be downloaded by that new tab instead of being rendered. What is the proper methodology to navigate the problem space of this unwanted behavior? The success condition would be Firefox ''not downloading the file at all'' and opening it like it is able to do in other instances. PS: I realize ''all content is actually downloaded'' '''anyway''', otherwise it wouldn't be possible to render it. However, this is done in the defined cache folder. I would like this behavior to extend to all files. Excluding, of course, executable binaries, as I understand that design decision is made for security reasons and to allow malware scanners to function properly. Thank you in advance.

All Replies (4)

more options

Just to confirm what you are saying: some web content opens in a new tab with a file:/// URL instead of opening in the same tab (or a new tab) with its original http:// or https:// URL.

One possible reason for this would be if the server sends the Content-Disposition: attachment header, which instructs the browser not to show the content in a tab but instead to download it. You could experiment with my add-on, which has an option to override that header:

https://addons.mozilla.org/firefox/addon/content-type-fixer/

After installation, its button will be on the drop-down from the recently added Extensions button. You can right-click it and Pin it to the main part of the toolbar for easier access.

Click the Zzzz button to start the listener, then click the button again and change the Content-Disposition Override to "Follow my setttings (inline)".

Another possible issue is if the server is misidentifying the file type by setting Content-Type to something inappropriate or generic to bypass viewing in a tab and force downloading. The add-on also can help with that, but you need to enable the override for image file extensions. For more information, see: https://www.jeffersonscher.com/ext/content-type-fixer.html

more options

jscher2000 - Support Volunteer said

Content-Disposition

Thank you very much for your reply, and for the link to your plugin. I'm sure the fault lies with me, but I wasn't able to invoke the desired effect. I got as far as viewing the log, and "adding" the new rule, but didn't experience any changes.

Two examples I can cite, when using outlook at someone sends you a PNG attachment, if you click this attachment, it will open in a frame popup. If you right click on the PNG in this frame, and select "open in new tab", Firefox will indeed open a new tab with the address of the file, but then it will not populate that tab with any rendered content, and instead download the PNG.

The second example is when someone writes a long post on Discord, the chat service. The way Discord handles out of buffer posts, is by converting it into some variation of "message1.txt" and if you click that, it will open your default browser, and then download that Plain Text file, instead of just rendering it, which it is more than capable of doing. I'm assuming the Content-Disposition you referenced is to blame.

What information could I provide to you, if you're willing to attempt diagnosing and resolving this with me?

Thanks in advance. :)

more options

For the image, it sounds like you are clicking the thumbnail to call up the larger preview first, then using right-click > Open Image in New Tab:

Did you already change the Content-Disposition Override? That should be all you need for that one:


If that doesn't also fix the problem with the .txt files, in the Log, what is showing on the C-T line for those files?

(By the way, I know this add-on needs a complete redesign, but every time I start, my ambitions overwhelm my will to continue...)

more options

In advanced settings (about:config) find browser.download.open_pdf_attachments_inline setting and change it to 'true.' I was just figuring this out myself... I hate the automatic downloading.