Skip to content

Commit 778b6f3

Browse files
committed
Update to handle request with invalid uri
1 parent 5958654 commit 778b6f3

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

app.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,17 @@ passport.deserializeUser(function (id, done) {
172172
});
173173
});
174174

175+
// check uri is valid before going further
176+
app.use(function(req, res, next) {
177+
try {
178+
decodeURIComponent(req.path);
179+
} catch (err) {
180+
logger.error(err);
181+
return response.errorBadRequest(res);
182+
}
183+
next();
184+
});
185+
175186
// redirect url with trailing slashes
176187
app.use(function(req, res, next) {
177188
if ("GET" == req.method && req.path.substr(-1) == '/' && req.path.length > 1) {

0 commit comments

Comments
 (0)