Closed Bug 1680147 Opened 4 years ago Closed 3 years ago

Opening local pdfs from file:///... fails if PDFs are set to "always ask"

Categories

(Firefox :: PDF Viewer, defect)

Desktop
All
defect

Tracking

()

VERIFIED FIXED
91 Branch
Tracking Status
firefox91 --- verified

People

(Reporter: smaug, Assigned: Gijs)

References

Details

Attachments

(2 files, 1 obsolete file)

Download (for example)
http://researcher.watson.ibm.com/researcher/files/us-bacon/Bacon01Concurrent.pdf

Go to the url pointing to the directory where the file was saved
Something like file:///home/<user>/Downloads
Click the pdf.
Dialog opens to let user to choose what to do with the pdf. Select "Open with Nightly".

That doesn't succeed, and an error dialog is shown.

I can reproduce easily in nightly in selecting "Always ask" for pdf in "Applications" section.
:gijs, maybe you'd have an idea here on what's wrong.

Flags: needinfo?(gijskruitbosch+bugs)

(In reply to Calixte Denizet (:calixte) from comment #1)

I can reproduce easily in nightly in selecting "Always ask" for pdf in "Applications" section.

Thanks for specifying this. The problem does not occur when picking "open in Firefox", which is the default for PDFs.

:gijs, maybe you'd have an idea here on what's wrong.

Not off-hand. I will try to investigate later this week.

OS: Unspecified → All
Hardware: Unspecified → Desktop
Summary: Opening local pdfs from file:///... fails → Opening local pdfs from file:///... fails if PDFs are set to "always ask"

So we avoid this if you open the PDF externally or with system principal, because we hit this code:

https://searchfox.org/mozilla-central/rev/bf8d5de8528036c09590009720bc172882845b80/toolkit/components/pdfjs/content/PdfStreamConverter.jsm#1123-1130

and allow handling directly with PDF.js

In this case, the triggering principal is a file principal (because that's where the link is!) and so we don't allow immediate opening with PDF.js . Which means we end up showing the "what do you want to do" dialog.

When the user picks Firefox in the dialog, we hit launchWithFile in the mime info implementation. This implementation is OS-dependent but either way it checks the "preferred action" (which is "handle internally") which it doesn't know how to do, so it returns NS_ERROR_INVALID_ARG, which causes the failure and dialog:

Windows: https://searchfox.org/mozilla-central/rev/bf8d5de8528036c09590009720bc172882845b80/uriloader/exthandler/win/nsMIMEInfoWin.cpp#88
macOS: https://searchfox.org/mozilla-central/rev/bf8d5de8528036c09590009720bc172882845b80/uriloader/exthandler/mac/nsMIMEInfoMac.mm#29
other: https://searchfox.org/mozilla-central/rev/bf8d5de8528036c09590009720bc172882845b80/uriloader/exthandler/nsMIMEInfoImpl.cpp#280

I'm not sure whether/how we should update them for this case, and if there are any other ways of triggering them besides this quirk of pdf.js-ness. Perhaps with the other file types where we now support handling them internally? But then, why would we ever show the dialog for them when clicking a file: link for them? Adam, you worked on the other filetypes - do you have any thoughts?

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(agashlin)

https://phabricator.services.mozilla.com/D116915 fixes this by immediately opening in PDF.js instead of opening the dialog first, but I don't know if the removal of the choice to use an external app in this case is going to upset anyone who somehow relies on using this to open external apps...

(In reply to :Gijs (out; back Jun 21; he/him) from comment #3)

I'm not sure whether/how we should update them for this case, and if there are any other ways of triggering them besides this quirk of pdf.js-ness. Perhaps with the other file types where we now support handling them internally? But then, why would we ever show the dialog for them when clicking a file: link for them? Adam, you worked on the other filetypes - do you have any thoughts?

I don't think the same thing can happen with the other types, though I don't understand fully the PDF issue here. When opening the other types from file: they always display regardless of whether we're set to always ask or to use a system handler. I tried the download attribute on a link, doesn't seem to work for file:, I think because same-origin checks are weird with file:.

Flags: needinfo?(agashlin)
Assignee: nobody → gijskruitbosch+bugs
Status: NEW → ASSIGNED
Attachment #9225343 - Attachment description: WIP: Bug 1680147 - open file: links to PDFs from file: pages with PDF.js immediately → Bug 1680147 - open file: links to PDFs from file: pages with PDF.js immediately
Pushed by gijskruitbosch@gmail.com: https://hg.mozilla.org/integration/autoland/rev/b929d6015258 open file: links to PDFs from file: pages with PDF.js immediately r=mtigley
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 91 Branch

I've reproduced this issue on mac 11, using an affected Nightly version (2020-12-01), and by following the steps from comment 0.

Hi Gijs! Just to make sure that I understand correctly this fix, the local pdf files will be opened immediately in Firefox, without prompting the dialog to the users, even though the "Always ask" option is checked for pdf. Is that correct? I've verified this on Win 10 x64, macOS 10.11 and Ubuntu 18.04 x64 with Beta 91.0b9.

Flags: needinfo?(gijskruitbosch+bugs)

(In reply to Ciprian Georgiu [:ciprian_georgiu], Release Desktop QA from comment #9)

I've reproduced this issue on mac 11, using an affected Nightly version (2020-12-01), and by following the steps from comment 0.

Hi Gijs! Just to make sure that I understand correctly this fix, the local pdf files will be opened immediately in Firefox, without prompting the dialog to the users, even though the "Always ask" option is checked for pdf. Is that correct? I've verified this on Win 10 x64, macOS 10.11 and Ubuntu 18.04 x64 with Beta 91.0b9.

yep, that's correct!

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(ciprian.georgiu)

Thank you! We can then close this bug as verified fixed, since I encountered that behavior on latest Beta 91, as mentioned in comment 9.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Flags: needinfo?(ciprian.georgiu)
Regressions: 1726501
Regressions: 1733362

Comment on attachment 9251710 [details]
Bug 1680147 - Rename LaunchWithApplication to SetDownloadToLaunch. r=gijs!

Revision D131714 was moved to bug 1740142. Setting attachment 9251710 [details] to obsolete.

Attachment #9251710 - Attachment is obsolete: true
See Also: → 1762955
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: