Strip null values for changelog and set size limit for large content blocks

This commit is contained in:
thiloho
2024-10-06 02:01:15 +02:00
parent b53f4c4859
commit 1b8f093f5b
5 changed files with 21 additions and 10 deletions

View File

@@ -63,6 +63,7 @@
<textarea
{name}
rows="20"
maxlength="200000"
bind:value={previewContent.value}
bind:this={mainContentTextarea}
onscroll={updateScrollPercentage}

View File

@@ -147,7 +147,13 @@ const createMarkdownParser = (showToc = true) => {
export const md = (markdownContent: string, showToc = true) => {
const marked = createMarkdownParser(showToc);
const html = DOMPurify.sanitize(marked.parse(markdownContent) as string);
let html = "";
try {
html = DOMPurify.sanitize(marked.parse(markdownContent, { async: false }));
} catch (_) {
html = "Failed to parse markdown";
}
return html;
};