Skip to content

Commit ae0316a

Browse files
committed
refac
1 parent a72e8e0 commit ae0316a

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/lib/components/chat/ChatPlaceholder.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
33
import { marked } from 'marked';
4+
import DOMPurify from 'dompurify';
45
56
import { config, user, models as _models, temporaryChatEnabled } from '$lib/stores';
67
import { onMount, getContext } from 'svelte';
@@ -96,11 +97,11 @@
9697
<div
9798
class="mt-0.5 text-base font-normal text-gray-500 dark:text-gray-400 line-clamp-3 markdown"
9899
>
99-
{@html marked.parse(
100+
{@html DOMPurify.sanitize(marked.parse(
100101
sanitizeResponseContent(
101102
models[selectedModelIdx]?.info?.meta?.description
102103
).replaceAll('\n', '<br>')
103-
)}
104+
))}
104105
</div>
105106
{#if models[selectedModelIdx]?.info?.meta?.user}
106107
<div class="mt-0.5 text-sm font-normal text-gray-400 dark:text-gray-500">

src/lib/components/chat/Placeholder.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import { toast } from 'svelte-sonner';
33
import { marked } from 'marked';
4+
import DOMPurify from 'dompurify';
45
56
import { onMount, getContext, tick, createEventDispatcher } from 'svelte';
67
import { blur, fade } from 'svelte/transition';
@@ -174,11 +175,11 @@
174175
<div
175176
class="mt-0.5 px-2 text-sm font-normal text-gray-500 dark:text-gray-400 line-clamp-2 max-w-xl markdown"
176177
>
177-
{@html marked.parse(
178+
{@html DOMPurify.sanitize(marked.parse(
178179
sanitizeResponseContent(
179180
models[selectedModelIdx]?.info?.meta?.description ?? ''
180181
).replaceAll('\n', '<br>')
181-
)}
182+
))}
182183
</div>
183184
</Tooltip>
184185

src/lib/components/layout/Overlay/AccountPending.svelte

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@
4141
style="white-space: pre-wrap;"
4242
>
4343
{#if ($config?.ui?.pending_user_overlay_content ?? '').trim() !== ''}
44-
{@html marked.parse(
45-
DOMPurify.sanitize(
46-
($config?.ui?.pending_user_overlay_content ?? '').replace(/\n/g, '<br>')
47-
)
48-
)}
44+
{@html DOMPurify.sanitize(marked.parse(
45+
($config?.ui?.pending_user_overlay_content ?? '').replace(/\n/g, '<br>')
46+
))}
4947
{:else}
5048
{$i18n.t('Your account status is currently pending activation.')}{'\n'}{$i18n.t(
5149
'To access the WebUI, please reach out to the administrator. Admins can manage user statuses from the Admin Panel.'

0 commit comments

Comments
 (0)