Fix document
property access errors in translation-server
For some reason, in the Fx48 translation-server, the processor passed to processDocuments() calls in translators can't access document properties even when they're on the same domain or even the same document. To get around that, rewrap them for the sandbox, but there might be a better fix here. Addresses https://github.com/zotero/translation-server/issues/36
This commit is contained in:
parent
06472a9d3c
commit
88e12f617c
1 changed files with 21 additions and 2 deletions
|
@ -257,7 +257,22 @@ Zotero.Utilities.Translate.prototype.processDocuments = function(urls, processor
|
|||
&& this._translate.document.location.toString() === urls[i]) {
|
||||
// Document is attempting to reload itself
|
||||
Zotero.debug("Translate: Attempted to load the current document using processDocuments; using loaded document instead");
|
||||
processor(this._translate.document, urls[i]);
|
||||
// This fixes document permissions issues in translation-server when translators call
|
||||
// processDocuments() on the original URL (e.g., AOSIC)
|
||||
// DEBUG: Why is this necessary? (see below also)
|
||||
if (Zotero.isServer) {
|
||||
processor(
|
||||
translate._sandboxManager.wrap(
|
||||
Zotero.Translate.DOMWrapper.unwrap(
|
||||
this._translate.document
|
||||
)
|
||||
),
|
||||
urls[i]
|
||||
);
|
||||
}
|
||||
else {
|
||||
processor(this._translate.document, urls[i]);
|
||||
}
|
||||
urls.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
|
@ -268,7 +283,11 @@ Zotero.Utilities.Translate.prototype.processDocuments = function(urls, processor
|
|||
if(!processor) return;
|
||||
|
||||
var newLoc = doc.location;
|
||||
if(Zotero.isFx && !Zotero.isBookmarklet && (protocol != newLoc.protocol || host != newLoc.host)) {
|
||||
if((Zotero.isFx && !Zotero.isBookmarklet && (protocol != newLoc.protocol || host != newLoc.host))
|
||||
// This fixes document permissions issues in translation-server when translators call
|
||||
// processDocuments() on same-domain URLs (e.g., some of the Code4Lib tests).
|
||||
// DEBUG: Is there a better fix for this?
|
||||
|| Zotero.isServer) {
|
||||
// Cross-site; need to wrap
|
||||
processor(translate._sandboxManager.wrap(doc), newLoc.toString());
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue