mirror of
https://github.com/FlowiseAI/Flowise.git
synced 2026-10-12 02:02:17 +00:00
Sanitize image url from DOM node (#5779)
* Sanitize text from DOM node * Update packages/ui/src/views/assistants/openai/AssistantDialog.jsx Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update AssistantDialog.jsx --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
gemini-code-assist[bot]
parent
a4e2bc3f59
commit
66374bfcc9
@@ -125,6 +125,25 @@ const AssistantDialog = ({ show, dialogProps, onCancel, onConfirm, setError }) =
|
||||
const customization = useSelector((state) => state.customization)
|
||||
const dialogRef = useRef()
|
||||
|
||||
// Sanitize image URL to prevent XSS attacks via javascript:, data:, or blob: schemes
|
||||
const sanitizeImageUrl = (url) => {
|
||||
const fallbackUrl = `https://api.dicebear.com/7.x/bottts/svg?seed=fallback`
|
||||
if (!url || typeof url !== 'string') {
|
||||
return fallbackUrl
|
||||
}
|
||||
try {
|
||||
const parsed = new URL(url, window.location.origin)
|
||||
// Only allow http and https protocols
|
||||
if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {
|
||||
return url
|
||||
}
|
||||
} catch (e) {
|
||||
// Invalid URL
|
||||
}
|
||||
// Return default avatar if URL is invalid or uses disallowed protocol
|
||||
return fallbackUrl
|
||||
}
|
||||
|
||||
const getSpecificAssistantApi = useApi(assistantsApi.getSpecificAssistant)
|
||||
const getAssistantObjApi = useApi(assistantsApi.getAssistantObj)
|
||||
|
||||
@@ -790,7 +809,7 @@ const AssistantDialog = ({ show, dialogProps, onCancel, onConfirm, setError }) =
|
||||
objectFit: 'contain'
|
||||
}}
|
||||
alt={assistantName}
|
||||
src={assistantIcon}
|
||||
src={sanitizeImageUrl(assistantIcon)}
|
||||
/>
|
||||
</div>
|
||||
<OutlinedInput
|
||||
|
||||
Reference in New Issue
Block a user