0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Added protection for incorrect i18n variable names

closes #9305

- add a try/catch when formatting messages
- fallback to the general error message if error ocurred
- log the error
This commit is contained in:
kirrg001 2017-12-04 17:13:12 +01:00
parent 0be734a05c
commit 533ae22c2b

View file

@ -34,11 +34,30 @@ I18n = {
string.forEach(function (s) {
var m = new MessageFormat(s, currentLocale);
msg.push(m.format(bindings));
try {
m.format(bindings);
} catch (err) {
logging.error(err.message);
// fallback
m = new MessageFormat(blos.errors.errors.anErrorOccurred, currentLocale);
m = msg.format();
}
msg.push(m);
});
} else {
msg = new MessageFormat(string, currentLocale);
try {
msg = msg.format(bindings);
} catch (err) {
logging.error(err.message);
// fallback
msg = new MessageFormat(blos.errors.errors.anErrorOccurred, currentLocale);
msg = msg.format();
}
}
return msg;