diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 3555029c9..68a3e1b5c 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -246,7 +246,8 @@ Zotero.Attachments = new function(){ /** * @param {Object} options - 'libraryID', 'url', 'parentItemID', 'collections', 'title', - * 'fileBaseName', 'contentType', 'cookieSandbox', 'saveOptions' + * 'fileBaseName', 'contentType', 'referrer', 'cookieSandbox', + * 'saveOptions' * @return {Promise} - A promise for the created attachment item */ this.importFromURL = Zotero.Promise.coroutine(function* (options) { @@ -257,6 +258,7 @@ Zotero.Attachments = new function(){ var title = options.title; var fileBaseName = options.fileBaseName; var contentType = options.contentType; + var referrer = options.referrer; var cookieSandbox = options.cookieSandbox; var saveOptions = options.saveOptions; @@ -347,7 +349,12 @@ Zotero.Attachments = new function(){ var nsIURL = Components.classes["@mozilla.org/network/standard-url;1"] .createInstance(Components.interfaces.nsIURL); nsIURL.spec = url; - Zotero.Utilities.Internal.saveURI(wbp, nsIURL, tmpFile); + var headers = {}; + if (referrer) { + headers.Referer = referrer; + } + Zotero.Utilities.Internal.saveURI(wbp, nsIURL, tmpFile, headers); + yield deferred.promise; let sample = yield Zotero.File.getContentsAsync(tmpFile, null, 1000); diff --git a/chrome/content/zotero/xpcom/server_connector.js b/chrome/content/zotero/xpcom/server_connector.js index cca34219e..5fd0b2fd7 100644 --- a/chrome/content/zotero/xpcom/server_connector.js +++ b/chrome/content/zotero/xpcom/server_connector.js @@ -539,6 +539,7 @@ Zotero.Server.Connector.SaveItem.prototype = { collections: collection ? [collection.id] : undefined, attachmentMode: Zotero.Translate.ItemSaver.ATTACHMENT_MODE_DOWNLOAD, forceTagType: 1, + referrer: data.uri, cookieSandbox, proxy }); diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index 0ceddc800..f4de9b410 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -54,6 +54,7 @@ Zotero.Translate.ItemSaver = function(options) { this.attachmentMode = Zotero.Libraries.get(this._libraryID).filesEditable ? options.attachmentMode : Zotero.Translate.ItemSaver.ATTACHMENT_MODE_IGNORE; this._forceTagType = options.forceTagType; + this._referrer = options.referrer; this._cookieSandbox = options.cookieSandbox; this._proxy = options.proxy; @@ -634,6 +635,7 @@ Zotero.Translate.ItemSaver.prototype = { title, fileBaseName, contentType: mimeType, + referrer: this._referrer, cookieSandbox: this._cookieSandbox, collections: !parentItemID ? this._collections : undefined });