mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-09-03 23:32:50 +02:00
fix: escape config.userLang/acpLang, don't allow invalid language codes
This commit is contained in:
@@ -123,14 +123,16 @@ if (typeof window !== 'undefined') {
|
||||
$.timeago.settings.allowFuture = true;
|
||||
var userLang = config.userLang.replace('_', '-');
|
||||
var options = { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' };
|
||||
var formatFn;
|
||||
if (typeof Intl === 'undefined') {
|
||||
formatFn = function (date) {
|
||||
return date.toLocaleString(userLang, options);
|
||||
};
|
||||
} else {
|
||||
var dtFormat = new Intl.DateTimeFormat(userLang, options);
|
||||
formatFn = dtFormat.format;
|
||||
var formatFn = function (date) {
|
||||
return date.toLocaleString(userLang, options);
|
||||
};
|
||||
try {
|
||||
if (typeof Intl !== 'undefined') {
|
||||
var dtFormat = new Intl.DateTimeFormat(userLang, options);
|
||||
formatFn = dtFormat.format;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
var iso;
|
||||
|
||||
Reference in New Issue
Block a user