From 03c64af1428e0cc11f8ab9c5520f629b440c39e0 Mon Sep 17 00:00:00 2001 From: TheRed Date: Mon, 11 Apr 2022 23:25:16 +0300 Subject: [PATCH] someone sent nsfw so i fixed that --- pages/api/submit.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pages/api/submit.js b/pages/api/submit.js index d05d3b9..ceb640e 100644 --- a/pages/api/submit.js +++ b/pages/api/submit.js @@ -1,4 +1,5 @@ const local = ['127.0.0.1', '1', '192.168.1.254']; +const disallowRegex = /(https|http):\/\/.*/; const allowed_chars = /^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,\/?;:'\[\]\{\}\\<>\-_+=*!#$0123456789\^]*$/; export default async function handle(req, res) { // Check if IP matches with the local IP @@ -9,6 +10,7 @@ export default async function handle(req, res) { const text = req.body?.text; if(!text) return res.status(400).send("Illegal request!"); if(!allowed_chars.test(text)) return res.status(400).send("The message you were trying to send contains disallowed symbols!"); + if(disallowRegex.test(text)) return res.status(400).send("Nuh-uh! You don't send links here."); const webhookRes = await fetch(process.env.WEBHOOK, { method: "POST", headers: {