From 96261369934379737a965030a75cd4ec47a39255 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Tue, 16 May 2023 20:28:58 -0700 Subject: [PATCH] Validate short URL length server-side --- functions/api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/api.js b/functions/api.js index 47efb8f..ee0bd03 100644 --- a/functions/api.js +++ b/functions/api.js @@ -68,6 +68,9 @@ export async function onRequestPost({ request, env }) { } if (!isRandomlyGenerated) { + if (shortUrl.length > 80) { + return new Response('The short URL is too long (maximum length is 80 characters).', { status: 400, headers: { 'Content-Type': 'text/plain; charset=UTF-8' } }); + } const message = `Sign this message to confirm you want to create https://alu.bz/${shortUrl} to redirect to ${fullUrl}.`; // Must match frontend exactly const signingAddress = verifyMessage(message, signature); const nftCount = await getNftCount(signingAddress); -- 2.47.3