diff --git a/lib/components/package.json b/lib/components/package.json index 21930710..d1a489ef 100644 --- a/lib/components/package.json +++ b/lib/components/package.json @@ -10,7 +10,8 @@ "lint": "eslint src" }, "dependencies": { - "@sugarlabs/mb4-assets": "*" + "@sugarlabs/mb4-assets": "*", + "dompurify": "^3.0.6" }, "peerDependencies": { "react": "~18.x", diff --git a/lib/components/src/SImageVector/index.tsx b/lib/components/src/SImageVector/index.tsx index bd44dc5c..d6f9ea7a 100644 --- a/lib/components/src/SImageVector/index.tsx +++ b/lib/components/src/SImageVector/index.tsx @@ -1,4 +1,5 @@ import { useEffect, useRef } from 'react'; +import DOMPurify from 'dompurify'; // -- stylesheet ----------------------------------------------------------------------------------- @@ -17,7 +18,8 @@ export default function (props: { useEffect(() => { const _wrapper = wrapper.current! as HTMLDivElement; - _wrapper.innerHTML = props.content; + const sanitizedContent = DOMPurify.sanitize(props.content); + _wrapper.innerHTML = sanitizedContent; }); // ---------------------------------------------------------------------------