Skip to content

Commit

Permalink
Fix: remove all xlink:href attributes in incoming SVG
Browse files Browse the repository at this point in the history
  • Loading branch information
cvasseng committed Feb 19, 2025
1 parent 48d3794 commit c7349b2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/sanitize.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import DOMPurify from 'dompurify';
export function sanitize(input) {
const window = new JSDOM('').window;
const purify = DOMPurify(window);
return purify.sanitize(input, { ADD_TAGS: ['foreignObject'] });
return purify.sanitize(input, {
ADD_TAGS: ['foreignObject'],
// Dissalow all xlinks in incoming SVG
FORBID_ATTR: ['xlink:href']
});
}

export default sanitize;

0 comments on commit c7349b2

Please sign in to comment.