fix: make sure users cant send too large of a content

This commit is contained in:
dusk 2024-08-24 14:36:12 +03:00
parent d7abd486b4
commit 4f81608303
Signed by: dusk
SSH Key Fingerprint: SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw
2 changed files with 2 additions and 1 deletions

View File

@ -26,7 +26,7 @@ const postAction = (client: any, scopes: string[]) => {
return async ({ request, cookies }: { request: Request, cookies: Cookies }) => {
const form = await request.formData()
const author = form.get("author")?.toString().replace(/([^_a-z0-9]+)/gi, '')
const content = form.get("content")?.toString()
const content = form.get("content")?.toString().substring(0, 512)
const scopedCookies = scopeCookies(cookies)
if (author === undefined || content === undefined) {
scopedCookies.set("sendError", "one of author or content fields are missing")

View File

@ -30,6 +30,7 @@
class="text-lg ml-0.5 bg-inherit resize-none text-shadow-white placeholder-shown:[text-shadow:none] [field-sizing:content]"
name="content"
placeholder="say meow!"
maxlength="512"
required
/>
<p class="place-self-end text-sm font-monospace">