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: {