From 39f87cb21689a912559d0498641db7d2de4a784d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Aug 2016 14:37:36 +0200 Subject: Server: catch JSON.parse exceptions --- server/middlewares/secure.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'server/middlewares') diff --git a/server/middlewares/secure.js b/server/middlewares/secure.js index 9779c14ac..fa000c6f0 100644 --- a/server/middlewares/secure.js +++ b/server/middlewares/secure.js @@ -34,8 +34,13 @@ function decryptBody (req, res, next) { return res.sendStatus(500) } - req.body.data = JSON.parse(decrypted) - delete req.body.key + try { + req.body.data = JSON.parse(decrypted) + delete req.body.key + } catch (err) { + logger.error('Error in JSON.parse', { error: err }) + return res.sendStatus(500) + } next() }) -- cgit v1.2.3