Don't let invalid translators break all translation
If a translator couldn't be parsed, `_translatorInfo` wouldn't be set, and that would somehow cause the translator info for subsequent detections to be out of sync with the code loading, and nothing would work. Putting a try/catch around the eval() allows subsequent translators to continue to work normally. (There might be a better fix, but this seems to work.) This was happening for Better BibTeX translators that were still installed without the extension (which they need to be parsed properly), causing all imports to break. https://forums.zotero.org/discussion/86613/error-id-1093166052-upload-of-ris-and-bibtex-data-failed
This commit is contained in:
parent
558ad20ce6
commit
31c928a3ff
1 changed files with 15 additions and 10 deletions
|
@ -1779,16 +1779,21 @@ Zotero.Translate.Base.prototype = {
|
|||
var parse = function(code) {
|
||||
Zotero.debug("Translate: Parsing code for " + translator.label + " "
|
||||
+ "(" + translator.translatorID + ", " + translator.lastUpdated + ")", 4);
|
||||
this._sandboxManager.eval(
|
||||
"var exports = {}, ZOTERO_TRANSLATOR_INFO = " + code,
|
||||
[
|
||||
"detect" + this._entryFunctionSuffix,
|
||||
"do" + this._entryFunctionSuffix,
|
||||
"exports",
|
||||
"ZOTERO_TRANSLATOR_INFO"
|
||||
],
|
||||
(translator.file ? translator.file.path : translator.label)
|
||||
);
|
||||
try {
|
||||
this._sandboxManager.eval(
|
||||
"var exports = {}, ZOTERO_TRANSLATOR_INFO = " + code,
|
||||
[
|
||||
"detect" + this._entryFunctionSuffix,
|
||||
"do" + this._entryFunctionSuffix,
|
||||
"exports",
|
||||
"ZOTERO_TRANSLATOR_INFO"
|
||||
],
|
||||
(translator.file ? translator.file.path : translator.label)
|
||||
);
|
||||
}
|
||||
catch (e) {
|
||||
Zotero.logError(e);
|
||||
}
|
||||
this._translatorInfo = this._sandboxManager.sandbox.ZOTERO_TRANSLATOR_INFO;
|
||||
}.bind(this);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue