From 1ed46bd47c5d96e23ea73b7c2a6667881e3ca0ce Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 7 Dec 2025 22:24:14 +0200 Subject: [PATCH] refactor(server): add validation for HTML/Markdown rendering --- apps/server/src/routes/api/other.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/server/src/routes/api/other.ts b/apps/server/src/routes/api/other.ts index c1a4710b0..e0a9fd4bc 100644 --- a/apps/server/src/routes/api/other.ts +++ b/apps/server/src/routes/api/other.ts @@ -31,6 +31,9 @@ function getIconUsage() { function renderMarkdown(req: Request) { const { markdownContent } = req.body; + if (!markdownContent || typeof markdownContent !== 'string') { + throw new Error('markdownContent parameter is required and must be a string'); + } return { htmlContent: markdownService.renderToHtml(markdownContent, "") } satisfies RenderMarkdownResponse; @@ -38,6 +41,9 @@ function renderMarkdown(req: Request) { function toMarkdown(req: Request) { const { htmlContent } = req.body; + if (!htmlContent || typeof htmlContent !== 'string') { + throw new Error('htmlContent parameter is required and must be a string'); + } return { markdownContent: markdown.toMarkdown(htmlContent) } satisfies ToMarkdownResponse;