front/lib/moment/moment.js: Avoid loading path-looking locales from fs

This commit is contained in:
npt-1707
2026-05-18 06:15:43 +08:00
parent 198ca5d410
commit 35dc9f9fa0

View File

@@ -1842,11 +1842,16 @@
return globalLocale;
}
function isLocaleNameSane(name) {
// Prevent names that look like filesystem paths, i.e contain '/' or '\'
return name.match('^[^/\\\\]*$') != null;
}
function loadLocale(name) {
var oldLocale = null;
// TODO: Find a better way to register and load all the locales in Node
if (!locales[name] && (typeof module !== 'undefined') &&
module && module.exports) {
module && module.exports && isLocaleNameSane(name)) {
try {
oldLocale = globalLocale._abbr;
var aliasedRequire = require;