Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

added same precautions to /links PUT endpoint

Steven Teya7254d7e2fe2
diff --git a/pages/api/links/[key]/index.ts b/pages/api/links/[key]/index.ts
index c942dbca53..2c83c9ed08 100644
--- a/pages/api/links/[key]/index.ts
+++ b/pages/api/links/[key]/index.ts
@@ -2,6 +2,8 @@ import { NextApiRequest, NextApiResponse } from "next";
import { deleteLink, editLink } from "@/lib/api/links";
import { Session, withUserAuth } from "@/lib/auth";
import prisma from "@/lib/prisma";
+import { BLACKLIST } from "@/lib/constants";
+import { getDomainWithoutWWW } from "@/lib/utils";
const domain = "dub.sh";
@@ -31,6 +33,9 @@ export default withUserAuth(
.status(400)
.json({ error: "Missing key or url or title or timestamp" });
}
+ if (BLACKLIST.has(getDomainWithoutWWW(url))) {
+ return res.status(400).json({ error: "Invalid url" });
+ }
const response = await editLink(
{
domain,