From 7bf897933302ef3869c385dc436c84aa217f60f3 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 17 Jun 2007 21:38:07 +0000 Subject: [PATCH] closes #644, washingtonpost.com translator broken for some reason, passing the DOM window, rather than the URL, when creating the sandbox fixed this issue. i'm not entirely sure why this is, but it seems like the javascript on the washingtonpost.com site might be modifying document.domain in such a way that this is necessary. --- chrome/content/zotero/browser.js | 3 ++- chrome/content/zotero/xpcom/translate.js | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index 1dce1ed2a..5009b7dba 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -63,7 +63,8 @@ var Zotero_Browser = new function() { "googlesyndication.com", "doubleclick.net", "questionmarket.com", - "atdmt.com" + "atdmt.com", + "aggregateknowledge.com" ]; var tools = { diff --git a/chrome/content/zotero/xpcom/translate.js b/chrome/content/zotero/xpcom/translate.js index 0f67d2553..04f5f0398 100644 --- a/chrome/content/zotero/xpcom/translate.js +++ b/chrome/content/zotero/xpcom/translate.js @@ -636,10 +636,11 @@ Zotero.Translate.prototype._generateSandbox = function() { if(this.type == "web" || this.type == "search") { // get sandbox URL - var sandboxURL = "http://www.example.com/"; + var sandboxLocation = "http://www.example.com/"; if(this.type == "web") { // use real URL, not proxied version, to create sandbox - sandboxURL = this.document.location.href; + sandboxLocation = this.document.defaultView; + Zotero.debug("binding sandbox to "+this.document.location.href); } else { // generate sandbox for search by extracting domain from translator // target, if one exists @@ -648,12 +649,13 @@ Zotero.Translate.prototype._generateSandbox = function() { var tempURL = this.translator[0].target.replace(/\\/g, "").replace(/\^/g, ""); var m = Zotero.Translate._searchSandboxRegexp.exec(tempURL); if(m) { - sandboxURL = m[0]; + sandboxLocation = m[0]; } - } + } + Zotero.debug("binding sandbox to "+sandboxLocation); } - Zotero.debug("binding sandbox to "+sandboxURL); - this._sandbox = new Components.utils.Sandbox(sandboxURL); + this._sandbox = new Components.utils.Sandbox(sandboxLocation); + this._sandbox.Zotero = new Object(); // add ingester utilities @@ -2059,7 +2061,6 @@ Zotero.Translate.TranslatorSearch = function(translate, translators) { */ Zotero.Translate.TranslatorSearch.prototype.execute = function() { if(!this.running) return; - if(this.checkDone()) return; // get next translator @@ -2133,6 +2134,7 @@ Zotero.Translate.TranslatorSearch.prototype.execute = function() { (this.translate.type == "import" && this.translate._sandbox.detectImport)) { var returnValue; + this.currentTranslator = translator; try { if(this.translate.type == "web") { returnValue = this.translate._sandbox.detectWeb(this.translate.document, this.translate.location); @@ -2149,10 +2151,9 @@ Zotero.Translate.TranslatorSearch.prototype.execute = function() { Zotero.debug("executed detectCode for "+translator.label); if(this.translate.type == "web" && this.translate.waitForCompletion) { - this.currentTranslator = translator; this.asyncMode = true; - // don't immediately execute + // don't immediately execute next return; } else if(returnValue) { this.processReturnValue(translator, returnValue);