]> git.ardis.lu - alu.bz/commitdiff
Validate short URL length server-side
authorArdis Lu <ardisglu@gmail.com>
Wed, 17 May 2023 03:28:58 +0000 (20:28 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 17 May 2023 03:28:58 +0000 (20:28 -0700)
functions/api.js

index 47efb8f5438a1a89d7a2299616234481a5494757..ee0bd031ae22e1e0fd6155178da7d0021afa5601 100644 (file)
@@ -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);
This page took 0.036731 seconds and 4 git commands to generate.