Merge pull request #1647 from npt-1707/fix_CVE-2022-24785

Fix potentially vulnerable cloned function
This commit is contained in:
Jokob @NetAlertX authored and GitHub committed 2026-05-18 12:18:45 +10:00
commit 9eaaf50caf
1 file changed
+6 -1
+6 -1
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;