[api-minor] Support the Content-Disposition filename in the Firefox PDF Viewer (bug 1694556, PR 9379 follow-up)

As can be seen [in the mozilla-central code](https://searchfox.org/mozilla-central/rev/a6db3bd67367aa9ddd9505690cab09b47e65a762/toolkit/components/pdfjs/content/PdfStreamConverter.jsm#1222-1225), we're already getting the Content-Disposition filename. However, that data isn't passed through to the viewer nor to the `PDFDataTransportStream`-implementation, which explains why it's currently being ignored.

*Please note:* This will also require a small mozilla-central patch, see https://bugzilla.mozilla.org/show_bug.cgi?id=1694556, to forward the necessary data to the viewer.
This commit is contained in:
Jonas Jenwald 2021-02-24 13:02:58 +01:00
parent 061637d3f4
commit 6fd899dc44
10 changed files with 55 additions and 30 deletions

View file

@ -451,6 +451,10 @@ function addLinkAttributes(link, { url, target, rel, enabled = true } = {}) {
link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
}
function isPdfFile(filename) {
return typeof filename === "string" && /\.pdf$/i.test(filename);
}
/**
* Gets the file name from a given URL.
* @param {string} url
@ -652,6 +656,7 @@ export {
DOMSVGFactory,
getFilenameFromUrl,
isFetchSupported,
isPdfFile,
isValidFetchUrl,
LinkTarget,
loadScript,