refac: enhanced response content sanitisation
'<' and '>' can be correctly displayed now
This commit is contained in:
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 type { Token } from 'marked';
|
||||
import { revertSanitizedResponseContent, unescapeHtml } from '$lib/utils';
|
||||
import { onMount } from 'svelte';
|
||||
@@ -14,7 +15,12 @@
|
||||
{#if token.type === 'escape'}
|
||||
{unescapeHtml(token.text)}
|
||||
{: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 === 'link'}
|
||||
<a href={token.href} target="_blank" rel="nofollow" title={token.title}>{token.text}</a>
|
||||
{:else if token.type === 'image'}
|
||||
|
||||
Reference in new issue
Block a user