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.
This commit is contained in:
parent
103c16a563
commit
9395af86f7
|
@ -244,12 +244,25 @@ Zotero.DataDirectory = {
|
||||||
"}"
|
"}"
|
||||||
, sandbox);
|
, sandbox);
|
||||||
|
|
||||||
// remove comments
|
(yield Zotero.File.getContentsAsync(prefsFile))
|
||||||
var prefsJs = yield Zotero.File.getContentsAsync(prefsFile);
|
.split(/\n/)
|
||||||
prefsJs = prefsJs.replace(/^#[^\r\n]*$/mg, "");
|
.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;
|
var prefs = sandbox.prefs;
|
||||||
|
|
||||||
// Check for data dir pref
|
// Check for data dir pref
|
||||||
|
|
Loading…
Reference in New Issue
Block a user