Does url.parse protect against ../ in a url?

让人想犯罪 __ 提交于 2020-01-24 00:29:07

问题


I want everything in a directory called public to be allowed to be served. What I have is:

let uri = require('url').parse(req.url).pathname;
let filePath = `${publicDir}/${uri}`;
// then simply check if the file exists.

Is the pathname property on the object returned by url.parse protected against injection attacks? I don't know what they would all be. But for example attacks like mysite.com/../../users/.

来源:https://stackoverflow.com/questions/47481784/does-url-parse-protect-against-in-a-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!