mirror of
https://github.com/ether/etherpad-lite.git
synced 2026-05-12 15:56:16 +02:00
Settings.js: exit gracefully if an invalid credentials.json is passed.
Before this commit, when passed a malformed credentials.json the application
crashed with a stack dump. Now we catch the error and fail in a controlled way
(like already done for settings.json).
Example of exception we no longer throw:
MALFORMEDJSON
^
SyntaxError: Unexpected token M in JSON at position 0
at JSON.parse (<anonymous>)
at Object.reloadSettings (<BASEDIR>/src/node/utils/Settings.js:390:24)
at Object.<anonymous> (<BASEDIR>/src/node/utils/Settings.js:543:9)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
This commit is contained in:
parent
8fa52659f5
commit
ab57edef33
@ -379,9 +379,14 @@ exports.reloadSettings = function reloadSettings() {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (credentialsStr) {
|
||||
credentialsStr = jsonminify(credentialsStr).replace(",]","]").replace(",}","}");
|
||||
credentials = JSON.parse(credentialsStr);
|
||||
try {
|
||||
if (credentialsStr) {
|
||||
credentialsStr = jsonminify(credentialsStr).replace(",]","]").replace(",}","}");
|
||||
credentials = JSON.parse(credentialsStr);
|
||||
}
|
||||
} catch(e) {
|
||||
console.error(`There was an error processing your credentials file from ${credentialsFilename}:` + e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
//loop trough the settings
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user