[Pkg-javascript-commits] [pdf.js] 51/157: [CRX] Respect download requests in main frame
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 06:46:33 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit ffbe6697302e22eca9c2e740ce40d8b7cf0cc996
Author: Rob Wu <rob at robwu.nl>
Date: Mon Jul 6 17:13:44 2015 +0200
[CRX] Respect download requests in main frame
When the URL contains "=download", respect the Content-Disposition
header in the Chrome extension.
---
extensions/chromium/pdfHandler.js | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/extensions/chromium/pdfHandler.js b/extensions/chromium/pdfHandler.js
index 6cb82ef..760e3db 100644
--- a/extensions/chromium/pdfHandler.js
+++ b/extensions/chromium/pdfHandler.js
@@ -34,9 +34,15 @@ function isPdfDownloadable(details) {
if (details.url.indexOf('pdfjs.action=download') >= 0) {
return true;
}
- // Display the PDF viewer regardless of the Content-Disposition header
- // if the file is displayed in the main frame.
- if (details.type === 'main_frame') {
+ // Display the PDF viewer regardless of the Content-Disposition header if the
+ // file is displayed in the main frame, since most often users want to view
+ // a PDF, and servers are often misconfigured.
+ // If the query string contains "=download", do not unconditionally force the
+ // viewer to open the PDF, but first check whether the Content-Disposition
+ // header specifies an attachment. This allows sites like Google Drive to
+ // operate correctly (#6106).
+ if (details.type === 'main_frame' &&
+ details.url.indexOf('=download') === -1) {
return false;
}
var cdHeader = (details.responseHeaders &&
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list