mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 05:11:24 +08:00
fix(ImagePreview): add relaxed sanitize rules for svg (#9293)
This commit is contained in:
parent
585e49ac65
commit
e3c52a6174
@ -1,4 +1,5 @@
|
||||
import { makeSvgSizeAdaptive } from '@renderer/utils'
|
||||
import DOMPurify from 'dompurify'
|
||||
|
||||
/**
|
||||
* Renders an SVG string inside a host element's Shadow DOM to ensure style encapsulation.
|
||||
@ -14,14 +15,11 @@ export function renderSvgInShadowHost(svgContent: string, hostElement: HTMLEleme
|
||||
throw new Error('Host element for SVG rendering is not available.')
|
||||
}
|
||||
|
||||
// FIXME: Sanitize the SVG content
|
||||
// const sanitizedContent = DOMPurify.sanitize(svgContent, {
|
||||
// USE_PROFILES: { svg: true, svgFilters: true },
|
||||
// RETURN_DOM_FRAGMENT: false,
|
||||
// RETURN_DOM: false
|
||||
// })
|
||||
|
||||
const sanitizedContent = svgContent
|
||||
// Sanitize the SVG content
|
||||
const sanitizedContent = DOMPurify.sanitize(svgContent, {
|
||||
USE_PROFILES: { svg: true, svgFilters: true },
|
||||
ADD_TAGS: ['style', 'defs', 'foreignObject']
|
||||
})
|
||||
|
||||
const shadowRoot = hostElement.shadowRoot || hostElement.attachShadow({ mode: 'open' })
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user