mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-10 06:34:41 +02:00
* Don't crash with bad string formats
* File listing: If we fail to get an archive listing, fix attempt to format the string with a non-object
This commit is contained in:
parent
5bd7ecdb88
commit
746bd5abd0
2 changed files with 29 additions and 13 deletions
|
@ -331,17 +331,25 @@ module.exports = function format(fmt, obj) {
|
|||
transformer = match[2];
|
||||
formatSpec = match[3];
|
||||
|
||||
value = getValue(obj, objPath);
|
||||
if(transformer) {
|
||||
value = transformValue(transformer, value);
|
||||
}
|
||||
try {
|
||||
value = getValue(obj, objPath);
|
||||
if(transformer) {
|
||||
value = transformValue(transformer, value);
|
||||
}
|
||||
|
||||
tokens = tokenizeFormatSpec(formatSpec || '');
|
||||
tokens = tokenizeFormatSpec(formatSpec || '');
|
||||
|
||||
if(_.isNumber(value)) {
|
||||
out += formatNumber(value, tokens);
|
||||
} else {
|
||||
out += formatString(value, tokens);
|
||||
if(_.isNumber(value)) {
|
||||
out += formatNumber(value, tokens);
|
||||
} else {
|
||||
out += formatString(value, tokens);
|
||||
}
|
||||
} catch(e) {
|
||||
if(e instanceof KeyError) {
|
||||
out += match[0]; // preserve full thing
|
||||
} else if(e instanceof ValueError) {
|
||||
out += value.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue