From 38df733a376f451226ef7128174876c9e875c392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Thu, 15 Sep 2016 13:29:20 +0300 Subject: [PATCH] Fixes overriden Zotero object in connector sandboxes Occurs when not using `with` statement, which is highly discouraged and unsupported in strict mode. --- .../zotero/tools/testTranslators/translatorTester.js | 4 ++-- chrome/content/zotero/xpcom/translation/translate.js | 9 ++++++--- styles | 2 +- translators | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index cbeab693d..298f16815 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -36,7 +36,7 @@ try { var Zotero; } -Zotero_TranslatorTesters = new function() { +var Zotero_TranslatorTesters = new function() { const TEST_TYPES = ["web", "import", "export", "search"]; var collectedResults = {}; @@ -190,7 +190,7 @@ Zotero_TranslatorTesters = new function() { * @param {Function} [debugCallback] A function to call to write debug output. If not present, * Zotero.debug will be used. */ -Zotero_TranslatorTester = function(translator, type, debugCallback) { +var Zotero_TranslatorTester = function(translator, type, debugCallback) { this.type = type; this.translator = translator; this.output = ""; diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index b6b855076..d645a089f 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -1741,9 +1741,12 @@ Zotero.Translate.Base.prototype = { this._sandboxManager = new Zotero.Translate.SandboxManager(this._sandboxLocation); } const createArrays = "['creators', 'notes', 'tags', 'seeAlso', 'attachments']"; - var src = "var Zotero = {};"+ - "Zotero.Item = function (itemType) {"+ - "const createArrays = "+createArrays+";"+ + var src = ""; + if (Zotero.isFx && !Zotero.isBookmarklet) { + src = "var Zotero = {};"; + } + src += "Zotero.Item = function (itemType) {"+ + "var createArrays = "+createArrays+";"+ "this.itemType = itemType;"+ "for(var i=0, n=createArrays.length; i