Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: sanitize search grounding image titles to prevent XSS (#13303)

Arvin Xu926de076d954
diff --git a/src/features/Conversation/Markdown/plugins/ImageSearchRef/Render.tsx b/src/features/Conversation/Markdown/plugins/ImageSearchRef/Render.tsx
index 8c44948a105..da5377755ae 100644
--- a/src/features/Conversation/Markdown/plugins/ImageSearchRef/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/ImageSearchRef/Render.tsx
@@ -127,9 +127,7 @@ const Render = memo<MarkdownElementProps<ImageSearchRefProperties>>(({ node, id
title={image.title ? stripHtml(image.title) : undefined}
>
<Flexbox gap={2}>
- {image.title && (
- <div className={styles.imageTitle} dangerouslySetInnerHTML={{ __html: image.title }} />
- )}
+ {image.title && <div className={styles.imageTitle}>{stripHtml(image.title)}</div>}
{image.domain && (
<Flexbox horizontal align="center" gap={4}>
<Image
diff --git a/src/features/Conversation/Messages/components/SearchGrounding.tsx b/src/features/Conversation/Messages/components/SearchGrounding.tsx
index c2de978607f..1a77eb10e94 100644
--- a/src/features/Conversation/Messages/components/SearchGrounding.tsx
+++ b/src/features/Conversation/Messages/components/SearchGrounding.tsx
@@ -269,10 +269,7 @@ const SearchGrounding = memo<GroundingSearch>(
>
<Flexbox gap={2}>
{item.title && (
- <div
- className={styles.imageTitle}
- dangerouslySetInnerHTML={{ __html: item.title }}
- />
+ <div className={styles.imageTitle}>{stripHtml(item.title)}</div>
)}
{item.domain && (
<Flexbox horizontal align="center" gap={4}>