diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-08-23 14:37:36 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-08-23 14:37:36 +0200 |
commit | 39f87cb21689a912559d0498641db7d2de4a784d (patch) | |
tree | 83d0b98b63dcfd62fee783dda9cc2027e1a090c3 /server/middlewares/secure.js | |
parent | 52672600223d840ab123cd48c4c4d0457ac2e1a1 (diff) | |
download | PeerTube-39f87cb21689a912559d0498641db7d2de4a784d.tar.gz PeerTube-39f87cb21689a912559d0498641db7d2de4a784d.tar.zst PeerTube-39f87cb21689a912559d0498641db7d2de4a784d.zip |
Server: catch JSON.parse exceptions
Diffstat (limited to 'server/middlewares/secure.js')
-rw-r--r-- | server/middlewares/secure.js | 9 |
1 files changed, 7 insertions, 2 deletions
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) { | |||
34 | return res.sendStatus(500) | 34 | return res.sendStatus(500) |
35 | } | 35 | } |
36 | 36 | ||
37 | req.body.data = JSON.parse(decrypted) | 37 | try { |
38 | delete req.body.key | 38 | req.body.data = JSON.parse(decrypted) |
39 | delete req.body.key | ||
40 | } catch (err) { | ||
41 | logger.error('Error in JSON.parse', { error: err }) | ||
42 | return res.sendStatus(500) | ||
43 | } | ||
39 | 44 | ||
40 | next() | 45 | next() |
41 | }) | 46 | }) |