From 026ad8bca417ae893cf2e1aadbc96c10be083f54 Mon Sep 17 00:00:00 2001 From: Mystikfluu Date: Sat, 11 Jun 2022 19:37:03 +0200 Subject: [PATCH] fixed crash when trying to set long bio --- server.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 0f4a00d..fad4d44 100644 --- a/server.js +++ b/server.js @@ -505,8 +505,14 @@ router.post("/api/setBio", async function(req,res) { res.json({"error":"no bio set!"}) return } + bio = encodeURIComponent(bio) + if(100 < bio.length) { + res.status(400) + res.json({"error":"the bio is too long!"}) + return + } let sql = `update zerotwohub.users set User_Bio=? where User_Name=?` - con.query(sql, [encodeURIComponent(bio),encodeURIComponent(res.locals.username)], function (err, result) { + con.query(sql, [bio,encodeURIComponent(res.locals.username)], function (err, result) { if (err) throw err; res.json({"success":"updated bio"}) });