mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 00:06:33 +02:00
fix: translator path traversal
This commit is contained in:
@@ -13,7 +13,11 @@ const files = fs.readdirSync(path.join(paths.nodeModules, '/timeago/locales'));
|
||||
Languages.timeagoCodes = files.filter(f => f.startsWith('jquery.timeago')).map(f => f.split('.')[2]);
|
||||
|
||||
Languages.get = async function (language, namespace) {
|
||||
const data = await fs.promises.readFile(path.join(languagesPath, language, `${namespace}.json`), 'utf8');
|
||||
const pathToLanguageFile = path.join(languagesPath, language, `${namespace}.json`);
|
||||
if (!pathToLanguageFile.startsWith(languagesPath)) {
|
||||
throw new Error('[[error:invalid-path]]');
|
||||
}
|
||||
const data = await fs.promises.readFile(pathToLanguageFile, 'utf8');
|
||||
const parsed = JSON.parse(data) || {};
|
||||
const result = await plugins.hooks.fire('filter:languages.get', {
|
||||
language,
|
||||
|
||||
Reference in New Issue
Block a user