Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: improve sanitzation to custom length
Marc Seitzb244cb367bbf
diff --git a/lib/utils/sanitize-html.ts b/lib/utils/sanitize-html.tsindex 167916d3..5f54f9de 100644--- a/lib/utils/sanitize-html.ts+++ b/lib/utils/sanitize-html.ts@@ -1,8 +1,8 @@import sanitizeHtml from "sanitize-html";-export function validateContent(html: string) {- if (html.length > 1000) {- throw new Error("Content cannot be longer than 1000 characters");+export function validateContent(html: string, length: number = 1000) {+ if (html.length > length) {+ throw new Error(`Content cannot be longer than ${length} characters`);}const sanitized = sanitizeHtml(html, {allowedTags: [],diff --git a/pages/api/teams/[teamId]/agreements/index.ts b/pages/api/teams/[teamId]/agreements/index.tsindex e65971ea..507c1dcf 100644--- a/pages/api/teams/[teamId]/agreements/index.ts+++ b/pages/api/teams/[teamId]/agreements/index.ts@@ -17,7 +17,10 @@ const createAgreementSchema = z.object({.string().min(1, "Name is required").max(150, "Name must be less than 150 characters"),- content: z.string().min(1, "Content is required").max(1500, "Content must be less than 1500 characters"),+ content: z+ .string()+ .min(1, "Content is required")+ .max(1500, "Content must be less than 1500 characters"),contentType: z.enum(["LINK", "TEXT"]).default("LINK"),requireName: z.boolean().default(false),});@@ -111,7 +114,7 @@ export default async function handle(const { name, content, contentType, requireName } = parseResult.data;// Sanitize content using existing sanitization logic- const sanitizedContent = validateContent(content);+ const sanitizedContent = validateContent(content, 1500);const agreement = await prisma.agreement.create({data: {