Tuesday, 25 April 2017

Node, express, process ".." symbol in url

I'm looking to get node (using express for routing) to resolve all occurrences of the ../ symbol in urls before performing any routing on the url.

For example if apache is queried at the url /a/b/../c/d/e/../../f, it will first resolve all the ../ symbols and will finally serve any content located at /a/c/f.

With node+express, however, /a/b/../c/d/e/../../f is taken literally and will not match routing for /a/c/f. My problem is that the following code will not respond to a request like /a/b/../c/d/e/../../f:

app.get('/a/c/f', function(req, res) {
   return res.status(200).json({ msg: 'it worked!' }); 
});

How can I get node+express to resolve ../ symbols in the url?



via Gershom Maes

No comments:

Post a Comment