www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 9395af86f76c71883a766986e91ec3b2cc025846
parent 103c16a56328cb789c73c304e9f1391041983211
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 14 Sep 2017 18:48:00 -0400

Fix "SyntaxError: unterminated string literal" on first run

This could happen when migrating prefs from Firefox when the prefs.js
file included a corrupted line.

Diffstat:
Mchrome/content/zotero/xpcom/dataDirectory.js | 23++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/chrome/content/zotero/xpcom/dataDirectory.js b/chrome/content/zotero/xpcom/dataDirectory.js @@ -244,12 +244,25 @@ Zotero.DataDirectory = { "}" , sandbox); - // remove comments - var prefsJs = yield Zotero.File.getContentsAsync(prefsFile); - prefsJs = prefsJs.replace(/^#[^\r\n]*$/mg, ""); + (yield Zotero.File.getContentsAsync(prefsFile)) + .split(/\n/) + .filter((line) => { + // Strip comments + return !line.startsWith('#') + // Only process lines in our pref branch + && line.includes(ZOTERO_CONFIG.PREF_BRANCH); + }) + // Process each line individually + .forEach((line) => { + try { + Zotero.debug("Processing " + line); + Components.utils.evalInSandbox(line, sandbox); + } + catch (e) { + Zotero.logError("Error processing prefs line: " + line); + } + }); - // evaluate - Components.utils.evalInSandbox(prefsJs, sandbox); var prefs = sandbox.prefs; // Check for data dir pref