diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index c8b6361929..d4f6e60663 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -195,22 +195,22 @@ Zotero.Attachments = new function(){ if (obj.status != 200 && obj.status != 204) { Zotero.debug("Attachment HEAD request returned with status code " + obj.status + " in Attachments.importFromURL()", 2); - return false; + var mimeType = ''; + } + else { + var mimeType = obj.channel.contentType; } - - var mimeType = obj.channel.contentType; var nsIURL = Components.classes["@mozilla.org/network/standard-url;1"] .createInstance(Components.interfaces.nsIURL); nsIURL.spec = url; - var ext = nsIURL.fileExtension; // Override MIME type to application/pdf if extension is .pdf -- // workaround for sites that respond to the HEAD request with an // invalid MIME type (https://www.zotero.org/trac/ticket/460) // // Downloaded file is inspected below and deleted if actually HTML - if (ext == 'pdf') { + if (nsIURL.fileName.match(/pdf$/) || url.match(/pdf$/)) { mimeType = 'application/pdf'; }