From 40206d2ede1c9963c4e4f718e1e203e5d901af73 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Tue, 4 Jun 2024 03:30:10 +0300 Subject: Extra validation --- api/routes/getInnerIPFSContent/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'api/routes/getInnerIPFSContent') diff --git a/api/routes/getInnerIPFSContent/index.js b/api/routes/getInnerIPFSContent/index.js index e17d038..b3a05cb 100644 --- a/api/routes/getInnerIPFSContent/index.js +++ b/api/routes/getInnerIPFSContent/index.js @@ -15,13 +15,14 @@ function fetchZblock(zblock, res){ }; module.exports = (req, res) => { console.log(req.query) - if ( (req.query.ipfs) && req.query.ipfs.length === 46 ){ + if ( (req.query.ipfs) && typeof req.query.ipfs === "string" && req.query.ipfs.length === 46 ){ + let ipfs = req.query.ipfs; regex= /Qm[A-Za-z0-9]{44}/; - if (regex.test(req.query.ipfs)){ - if (req.query.ipfs === "QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" ){ + if (regex.test(ipfs)){ + if (ipfs === "QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH" ){ res.send({error:"Genesis block"}); } else { - fetchZblock(req.query.ipfs,res); + fetchZblock(ipfs,res); } } else { res.send({error:"Invalid data: regexp failed to pass"}); -- cgit v1.2.3