fix: sanitize model description HTML with DOMPurify in chat placeholders (#23621)
This commit is contained in:
@@ -46,11 +46,11 @@
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={marked.parse(
|
content={DOMPurify.sanitize(marked.parse(
|
||||||
sanitizeResponseContent(
|
sanitizeResponseContent(
|
||||||
models[selectedModelIdx]?.info?.meta?.description ?? ''
|
models[selectedModelIdx]?.info?.meta?.description ?? ''
|
||||||
).replaceAll('\n', '<br>')
|
).replaceAll('\n', '<br>')
|
||||||
)}
|
))}
|
||||||
placement="right"
|
placement="right"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
@@ -97,13 +97,11 @@
|
|||||||
<div
|
<div
|
||||||
class="mt-0.5 text-base font-normal text-gray-500 dark:text-gray-400 line-clamp-3 markdown"
|
class="mt-0.5 text-base font-normal text-gray-500 dark:text-gray-400 line-clamp-3 markdown"
|
||||||
>
|
>
|
||||||
{@html DOMPurify.sanitize(
|
{@html DOMPurify.sanitize(marked.parse(
|
||||||
marked.parse(
|
sanitizeResponseContent(
|
||||||
sanitizeResponseContent(
|
models[selectedModelIdx]?.info?.meta?.description
|
||||||
models[selectedModelIdx]?.info?.meta?.description
|
).replaceAll('\n', '<br>')
|
||||||
).replaceAll('\n', '<br>')
|
))}
|
||||||
)
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
{#if models[selectedModelIdx]?.info?.meta?.user}
|
{#if models[selectedModelIdx]?.info?.meta?.user}
|
||||||
<div class="mt-0.5 text-sm font-normal text-gray-400 dark:text-gray-500">
|
<div class="mt-0.5 text-sm font-normal text-gray-400 dark:text-gray-500">
|
||||||
|
|||||||
@@ -165,23 +165,21 @@
|
|||||||
{#if models[selectedModelIdx]?.info?.meta?.description ?? null}
|
{#if models[selectedModelIdx]?.info?.meta?.description ?? null}
|
||||||
<Tooltip
|
<Tooltip
|
||||||
className=" w-fit"
|
className=" w-fit"
|
||||||
content={marked.parse(
|
content={DOMPurify.sanitize(marked.parse(
|
||||||
sanitizeResponseContent(
|
sanitizeResponseContent(
|
||||||
models[selectedModelIdx]?.info?.meta?.description ?? ''
|
models[selectedModelIdx]?.info?.meta?.description ?? ''
|
||||||
).replaceAll('\n', '<br>')
|
).replaceAll('\n', '<br>')
|
||||||
)}
|
))}
|
||||||
placement="top"
|
placement="top"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="mt-0.5 px-2 text-sm font-normal text-gray-500 dark:text-gray-400 line-clamp-2 max-w-xl markdown"
|
class="mt-0.5 px-2 text-sm font-normal text-gray-500 dark:text-gray-400 line-clamp-2 max-w-xl markdown"
|
||||||
>
|
>
|
||||||
{@html DOMPurify.sanitize(
|
{@html DOMPurify.sanitize(marked.parse(
|
||||||
marked.parse(
|
sanitizeResponseContent(
|
||||||
sanitizeResponseContent(
|
models[selectedModelIdx]?.info?.meta?.description ?? ''
|
||||||
models[selectedModelIdx]?.info?.meta?.description ?? ''
|
).replaceAll('\n', '<br>')
|
||||||
).replaceAll('\n', '<br>')
|
))}
|
||||||
)
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user