From 7ee6e80fda12adfd523024bfcb05d6f12d7b02a7 Mon Sep 17 00:00:00 2001 From: Christoph Wiechert Date: Sun, 7 May 2017 23:15:31 +0200 Subject: [PATCH] Fix: handle zip-download for not existing bundle --- lib/endpoints.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/endpoints.js b/lib/endpoints.js index b39214c..184c7f3 100644 --- a/lib/endpoints.js +++ b/lib/endpoints.js @@ -86,6 +86,8 @@ app.get('/files/:fid', async(req, res, next) => { const format = req.params.fid.endsWith('.zip') ? 'zip' : 'tar.gz'; const bucket = db.get(sid); + if(!bucket) return res.status(404).send(errorPage.replace('%%ERROR%%', 'Download bucket not found.')); + if(req.params.fid !== sid + '++' + MD5(bucket.map(f => f.key).join()).toString() + '.' + format) { res.status(404).send(errorPage.replace('%%ERROR%%', 'Invalid link')); return;