Skip to content

pantoken / packages/utils/src / sanitizeSvg

Function: sanitizeSvg()

sanitizeSvg(svg): string

Beta

Strip <script> elements and event-handler attributes from SVG markup.

Defense-in-depth for SVG decoded from vendored data URIs or contributed by plugins. Not a full HTML parser — relies on the upstream source being trusted and pinned.

Parameters

svg

string

Returns

string