6 support issues
- All
- Questions
- Suggestions
- Problems
Karen Smith
Apr 6, 2020
I wanted this to work -- but it didn't
Our government website only opens PDFs in Edge. All other browsers are forced to download these documents (I hate desktop clutter): https://pubsaskdev.blob.core.windows.net/pubsask-prod/.
- Report illegal content
- Copy link
Gio -
Nov 6, 2019
Great extension
Hi, I find your extension very useful, but I need to tweak it in order to correctly work with pdfs found in my intranet.
Can I just take your code, give credit for it and link at your page, but also modify it and republish it on Chrome store with my additions?
Thanks in advance
- Report illegal content
- Copy link
Graham Jones
Jun 9, 2017
No longer works
Simply doesn't work any more.
- Report illegal content
- Copy link
Daniel San
Feb 20, 2015
Security issues
The extension works great, thank you so much for creating it!
However version 0.3 has a couple of security problems:
1. It removes the content-type altogether instead of setting it to "application/pdf". If the file is actually HTML, the browser would run its content in the context of the site (e.g. Google Drive -> someone could get your Google login cookie).
2. It checks if the filename contains ".pdf" instead of checking if it ends in ".pdf". Someone can name a file evil.pdf.html and for the result see point 1.
Here is a safer version (it only acts if the content-type is pdf, octet-stream, x-forcedownload or missing AND the file name ends with .pdf; it always sets the content-type to pdf):
chrome.webRequest.onHeadersReceived.addListener(function (details) {
try {
var hasType = false;
var typeIsDownload = false;
var typeIsPdf = false;
var typeIsBinary = false;
var filenameIsPdf = false;
for (var i = 0; i < details.responseHeaders.length; i++) {
if (details.responseHeaders[i].name.toLowerCase() == 'content-type') {
hasType = true;
}
if (details.responseHeaders[i].name.toLowerCase() == 'content-type' &&
details.responseHeaders[i].value.toLowerCase() == 'application/x-forcedownload') {
typeIsDownload = true;
}
if (details.responseHeaders[i].name.toLowerCase() == 'content-type' &&
details.responseHeaders[i].value.toLowerCase() == 'application/pdf') {
typeIsPdf = true;
}
if (details.responseHeaders[i].name.toLowerCase() == 'content-type' &&
details.responseHeaders[i].value.toLowerCase() == 'application/octet-stream') {
typeIsBinary = true;
}
if (details.responseHeaders[i].name.toLowerCase() == 'content-disposition' &&
details.responseHeaders[i].value.match(/.* filename=".*\.pdf"$/i)) {
filenameIsPdf = true;
}
}
for (var i = 0; i < details.responseHeaders.length; i++) {
if (details.responseHeaders[i].name.toLowerCase() == 'content-type' &&
details.responseHeaders[i].value.toLowerCase() == 'application/x-forcedownload' &&
filenameIsPdf) {
details.responseHeaders[i].value = 'application/pdf';
}
if (details.responseHeaders[i].name.toLowerCase() == 'content-type' &&
details.responseHeaders[i].value.toLowerCase() == 'application/octet-stream' &&
filenameIsPdf) {
details.responseHeaders[i].value = 'application/pdf';
}
if (details.responseHeaders[i].name.toLowerCase() == 'content-disposition' &&
details.responseHeaders[i].value.match(/.* filename=".*\.pdf"$/i) &&
(typeIsDownload || typeIsPdf || typeIsBinary || !hasType)) {
details.responseHeaders[i].value = details.responseHeaders[i].value.replace(/^attachment/i, 'inline');
if (!hasType) {
details.responseHeaders[details.responseHeaders.length] = {
name: "Content-Type",
value: "application/pdf"
};
}
}
}
} catch (err)
{}
return {responseHeaders:details.responseHeaders};
}, {urls: ['*://*/*.pdf*']}, ['blocking', 'responseHeaders']);
- Report illegal content
- Copy link
Dan Root
Dec 3, 2013
Freshbooks PDF View
Hello! I was so excited when I saw this plugin... Unfortunately, I notice that "PDF" Freshbooks invoices are still downloading rather than opening. Not sure if they use the same technique as Google Docs which there is no way to force, but would you mind looking into it? I have an AWESOME printer that I can only print to via my Mac on Chrome Cloud Printer and when PDFs download (rather than open in the browser) I am forced to manually re-open them again just to print them.
Any help is appreciated! Thanks.
- Report illegal content
- Copy link
George Solomos
Apr 1, 2013
Export to PDF from Google Docs
Hi Brenton,
Unfortunately this extension causes exporting to PDF from Docs to break. Could you please look into this and maybe add a simple settings dialog to add domains as exceptions?
Thanks,
George.
- Report illegal content
- Copy link