better input validation for post endpoint
This commit is contained in:
parent
7f408cd87c
commit
6b86ab0223
@ -351,6 +351,14 @@ router.get("/api/getotheruser",async function(req,res) {
|
||||
})
|
||||
|
||||
router.post("/api/post", async function(req,res) {
|
||||
if(!req.body.message) {
|
||||
res.json({"error":"no message to post"})
|
||||
return
|
||||
}
|
||||
if((typeof req.body.message) != "string") {
|
||||
res.json({"error":"no message to post"})
|
||||
return
|
||||
}
|
||||
req.body.message = encodeURIComponent(req.body.message.trim())
|
||||
if(!req.body.message) {
|
||||
res.json({"error":"no message to post"})
|
||||
|
Loading…
x
Reference in New Issue
Block a user