From 2f41df7264694cfdafaccc7cd2e1f936d3754196 Mon Sep 17 00:00:00 2001 From: Wolvan Date: Wed, 29 Dec 2021 19:26:07 +0100 Subject: [PATCH] Allow only 300 characters max This prevents people from going crazy with gigabytes of data. --- src/backend.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend.ts b/src/backend.ts index d131f83..182774e 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -75,10 +75,10 @@ export default async function init(router: Router): Promise { dupeCheckMode === "cookie" ? randomString(16) : null; const poll: Poll = { id, - title: req.body.title || "", + title: (req.body.title || "").trim().slice(0, 300), options: (() => { const result: { [option: string]: number } = {}; - for (const option of options) { + for (const option of options.map(i => i.trim().slice(0, 300))) { if (option) result[option] = 0; } return result;