fix: Force all paths to be within `cwd()`
parent
39155e627f
commit
a04c4bc893
6
index.js
6
index.js
|
@ -154,7 +154,11 @@ app.use((req, res, next) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function relative(...paths) {
|
function relative(...paths) {
|
||||||
return paths.reduce((a, b) => path.join(a, b), process.cwd());
|
const finalPath = paths.reduce((a, b) => path.join(a, b), process.cwd());
|
||||||
|
if (path.relative(process.cwd(), finalPath).startsWith("..")) {
|
||||||
|
throw new Error("Failed to resolve path outside of the working directory")
|
||||||
|
}
|
||||||
|
return finalPath;
|
||||||
}
|
}
|
||||||
function flashify(req, obj) {
|
function flashify(req, obj) {
|
||||||
let error = req.flash("error");
|
let error = req.flash("error");
|
||||||
|
|
Loading…
Reference in New Issue