Fix example in JavaScript query

This commit is contained in:
Edoardo Pirovano
2021-12-29 12:01:09 +00:00
parent 882caf4011
commit a616059761
2 changed files with 5 additions and 5 deletions

View File

@@ -4,8 +4,8 @@ var app = require("express")(),
app.get("/user-files", function(req, res) {
var file = req.param("file");
if (file.indexOf("..") !== -1) {
// BAD
// forbid paths outside the /public directory
// BAD: we forbid relative paths that contain ..
// as these could leave the public directory
res.status(400).send("Bad request");
} else {
var absolute = path.resolve("/public/" + file);

View File

@@ -3,9 +3,9 @@ var app = require("express")(),
app.get("/user-files", function(req, res) {
var file = req.param("file");
if (typeof path !== 'string' || file.indexOf("..") !== -1) {
// BAD
// forbid paths outside the /public directory
if (typeof file !== 'string' || file.indexOf("..") !== -1) {
// BAD: we forbid relative paths that contain ..
// as these could leave the public directory
res.status(400).send("Bad request");
} else {
var absolute = path.resolve("/public/" + file);