mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
fix: make sure theme screenshot starts with themeDir
This commit is contained in:
@@ -20,12 +20,18 @@ themesController.get = async function (req, res, next) {
|
|||||||
themeConfig = JSON.parse(themeConfig);
|
themeConfig = JSON.parse(themeConfig);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code === 'ENOENT') {
|
if (err.code === 'ENOENT') {
|
||||||
return next(Error('invalid-data'));
|
return next(Error('[[error:invalid-data]]'));
|
||||||
}
|
}
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const screenshotPath = themeConfig.screenshot ? path.join(themeDir, themeConfig.screenshot) : defaultScreenshotPath;
|
const screenshotPath = themeConfig.screenshot ?
|
||||||
const exists = await file.exists(screenshotPath);
|
path.join(themeDir, themeConfig.screenshot) :
|
||||||
|
'';
|
||||||
|
|
||||||
|
if (screenshotPath && !screenshotPath.startsWith(themeDir)) {
|
||||||
|
throw new Error('[[error:invalid-path]]');
|
||||||
|
}
|
||||||
|
const exists = screenshotPath ? await file.exists(screenshotPath) : false;
|
||||||
res.sendFile(exists ? screenshotPath : defaultScreenshotPath);
|
res.sendFile(exists ? screenshotPath : defaultScreenshotPath);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user