Merge pull request #11917 from Snuffleupagus/bug-1632644
[Firefox] Allow PDF attachments to, once again, be opened directly in the browser (bug 1632644)
This commit is contained in:
commit
0960e6c0b5
@ -1858,7 +1858,7 @@ function webViewerInitialized() {
|
||||
file = "file" in params ? params.file : AppOptions.get("defaultUrl");
|
||||
validateFileURL(file);
|
||||
} else if (PDFJSDev.test("MOZCENTRAL")) {
|
||||
file = window.location.href.split("#")[0];
|
||||
file = window.location.href;
|
||||
} else if (PDFJSDev.test("CHROME")) {
|
||||
file = AppOptions.get("defaultUrl");
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class PDFAttachmentViewer {
|
||||
viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
|
||||
} else if (PDFJSDev.test("MOZCENTRAL")) {
|
||||
// Let Firefox's content handler catch the URL and display the PDF.
|
||||
viewerUrl = blobUrl + "?" + encodeURIComponent(filename);
|
||||
viewerUrl = blobUrl + "#filename=" + encodeURIComponent(filename);
|
||||
} else if (PDFJSDev.test("CHROME")) {
|
||||
// In the Chrome extension, the URL is rewritten using the history API
|
||||
// in viewer.js, so an absolute URL must be generated.
|
||||
|
@ -132,7 +132,7 @@ class PDFDocumentProperties {
|
||||
return Promise.all([
|
||||
info,
|
||||
metadata,
|
||||
contentDispositionFilename || getPDFFileNameFromURL(this.url || ""),
|
||||
contentDispositionFilename || getPDFFileNameFromURL(this.url),
|
||||
this._parseFileSize(this.maybeFileSize),
|
||||
this._parseDate(info.CreationDate),
|
||||
this._parseDate(info.ModDate),
|
||||
|
@ -610,7 +610,7 @@ function getPDFFileNameFromURL(url, defaultFilename = "document.pdf") {
|
||||
return defaultFilename;
|
||||
}
|
||||
const reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
|
||||
// SCHEME HOST 1.PATH 2.QUERY 3.REF
|
||||
// SCHEME HOST 1.PATH 2.QUERY 3.REF
|
||||
// Pattern to get last matching NAME.pdf
|
||||
const reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
|
||||
const splitURI = reURI.exec(url);
|
||||
|
Loading…
Reference in New Issue
Block a user