diff --git a/src/utils/sanitize.ts b/src/utils/sanitize.ts index 483753b..e796042 100644 --- a/src/utils/sanitize.ts +++ b/src/utils/sanitize.ts @@ -30,6 +30,13 @@ function sanitize(purify: DOMPurifyI, parser: DOMParser, dirty: string): string fixURLOrigin(dom) + purify.addHook('afterSanitizeAttributes', function (node) { + if (node.tagName === 'A') { + node.setAttribute('target', '_blank') + node.setAttribute('rel', 'noopener') + } + }) + const clean = purify.sanitize(dom.body, { ADD_TAGS: ['iframe'], })