diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/friends.js | 7 | ||||
-rw-r--r-- | server/middlewares/secure.js | 9 |
2 files changed, 13 insertions, 3 deletions
diff --git a/server/lib/friends.js b/server/lib/friends.js index 667055d4c..6c4383d8e 100644 --- a/server/lib/friends.js +++ b/server/lib/friends.js | |||
@@ -198,7 +198,12 @@ function getForeignPodsList (url, callback) { | |||
198 | request.get(url + path, function (err, response, body) { | 198 | request.get(url + path, function (err, response, body) { |
199 | if (err) return callback(err) | 199 | if (err) return callback(err) |
200 | 200 | ||
201 | callback(null, JSON.parse(body)) | 201 | try { |
202 | const json = JSON.parse(body) | ||
203 | return callback(null, json) | ||
204 | } catch (err) { | ||
205 | return callback(err) | ||
206 | } | ||
202 | }) | 207 | }) |
203 | } | 208 | } |
204 | 209 | ||
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 | }) |