[Firefox] Allow PDF attachments to, once again, be opened directly in the browser (bug 1632644) #11917
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Apparently the old link format used in MOZCENTRAL-builds, with the blob URL separated from the filename with a
?
character violates the specification; see https://bugzilla.mozilla.org/show_bug.cgi?id=1632644#c5Obviously just removing the
?
-part of the URL would have worked, but that would also have meant that we'd no longer be able to provide the correct filename when the user attempts to download the opened PDF attachment.To fix this we'll instead append the filename in the hash-part of the URL, which however required using a custom hash-parameter to avoid triggering the fallback "named destination" code-paths in the viewer.
Note that only changing the
web/pdf_attachment_viewer.js
file wasn't sufficient to fix the bug, and we also need to tweak thewebViewerInitialized
function inweb/app.js
since MOZCENTRAL-builds used to ignore everything in the URL hash.This particular code is very old, but changing it should be completely safe given that the
PDFViewerApplication.setTitleUsingUrl
method since some time now stores both the original URL (inthis.url
) as well as one without the hash (inthis.baseUrl
). The latter one is already used everywhere where it matters, so this change seem fine to me.This patch thus restores the original behaviour for PDF attachments in the MOZCENTRAL-build, by once again allowing them to be opened directly in the browser without downloading. (The fallback added in PR #11845 is obviously kept, since it seems generally useful to have.)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1632644