mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 05:24:02 +00:00
fix: node tooltip xss issue
Co-Authored-By: Valentino Stillhardt <4715129+Fusseldieb@users.noreply.github.com>
This commit is contained in:
parent
e35883ca9c
commit
5f15e9ee68
@ -15,6 +15,7 @@
|
|||||||
<Tooltip
|
<Tooltip
|
||||||
content={data?.message?.error ? data.message.error.content : data.message.content}
|
content={data?.message?.error ? data.message.error.content : data.message.content}
|
||||||
class="w-full"
|
class="w-full"
|
||||||
|
allowHTML={false}
|
||||||
>
|
>
|
||||||
{#if data.message.role === 'user'}
|
{#if data.message.role === 'user'}
|
||||||
<div class="flex w-full">
|
<div class="flex w-full">
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import DOMPurify from 'dompurify';
|
||||||
|
|
||||||
import { onDestroy } from 'svelte';
|
import { onDestroy } from 'svelte';
|
||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
|
|
||||||
@ -10,18 +12,19 @@
|
|||||||
export let touch = true;
|
export let touch = true;
|
||||||
export let className = 'flex';
|
export let className = 'flex';
|
||||||
export let theme = '';
|
export let theme = '';
|
||||||
|
export let allowHTML = true;
|
||||||
|
|
||||||
let tooltipElement;
|
let tooltipElement;
|
||||||
let tooltipInstance;
|
let tooltipInstance;
|
||||||
|
|
||||||
$: if (tooltipElement && content) {
|
$: if (tooltipElement && content) {
|
||||||
if (tooltipInstance) {
|
if (tooltipInstance) {
|
||||||
tooltipInstance.setContent(content);
|
tooltipInstance.setContent(DOMPurify.sanitize(content));
|
||||||
} else {
|
} else {
|
||||||
tooltipInstance = tippy(tooltipElement, {
|
tooltipInstance = tippy(tooltipElement, {
|
||||||
content: content,
|
content: DOMPurify.sanitize(content),
|
||||||
placement: placement,
|
placement: placement,
|
||||||
allowHTML: true,
|
allowHTML: allowHTML,
|
||||||
touch: touch,
|
touch: touch,
|
||||||
...(theme !== '' ? { theme } : { theme: 'dark' }),
|
...(theme !== '' ? { theme } : { theme: 'dark' }),
|
||||||
arrow: false,
|
arrow: false,
|
||||||
@ -41,6 +44,6 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:this={tooltipElement} aria-label={content} class={className}>
|
<div bind:this={tooltipElement} aria-label={DOMPurify.sanitize(content)} class={className}>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user