refac: enhanced response content sanitisation

'<' and '>' can be correctly displayed now
This commit is contained in:
Timothy J. Baek committed 2024-08-15 00:08:15 +02:00
1 parent c8badfe21f
commit 5a6ece9513
7 files changed
+39 -43

No files matched your search

@@ -1,4 +1,5 @@
<script lang="ts">
import DOMPurify from 'dompurify';
import { onMount } from 'svelte';
import type { Token } from 'marked';
import { revertSanitizedResponseContent, unescapeHtml } from '$lib/utils';
@@ -91,7 +92,12 @@
</ul>
{/if}
{:else if token.type === 'html'}
{@html token.text}
{@const html = DOMPurify.sanitize(token.text)}
{#if html}
{@html html}
{:else}
{token.text}
{/if}
{:else if token.type === 'paragraph'}
<p>
<MarkdownInlineTokens id={`${id}-${tokenIdx}-p`} tokens={token.tokens ?? []} />