Fix ScienceDirect PDF downloads
ScienceDirect sometimes puts the `name` directive at the end of the Content-Type
header instead of in Content-Disposition. That isn't strictly spec-approved, but
there are other directives (`charset` and `boundary`) that can also be appended
to Content-Type per the spec. We want to strip them before looking for handlers.
https://forums.zotero.org/discussion/105194/sciencedirect-pdf-downloads-not-working-zotero-7
(cherry picked from commit a4c3f5267b
)
This commit is contained in:
parent
117bc45ed4
commit
8f3f3c9b86
1 changed files with 3 additions and 1 deletions
|
@ -142,8 +142,10 @@ Zotero.MIMETypeHandler = new function () {
|
|||
if(channel.loadFlags & Components.interfaces.nsIHttpChannel.LOAD_DOCUMENT_URI) {
|
||||
channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
try {
|
||||
// Get the main directive of the Content-Type header
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type#syntax
|
||||
var contentType = channel.getResponseHeader("Content-Type").split(';')[0].toLowerCase();
|
||||
// remove content-disposition headers for EndNote, etc.
|
||||
var contentType = channel.getResponseHeader("Content-Type").toLowerCase();
|
||||
for (let handledType of _ignoreContentDispositionTypes) {
|
||||
if (contentType.startsWith(handledType)) {
|
||||
channel.setResponseHeader("Content-Disposition", "inline", false);
|
||||
|
|
Loading…
Reference in a new issue