We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d7e0477 + 6babf16 commit 79f5d35Copy full SHA for 79f5d35
resources/js/utils/sanitize.ts
@@ -1,9 +1,16 @@
1
import DOMPurify from 'dompurify';
2
3
+DOMPurify.addHook('afterSanitizeAttributes', function (node) {
4
+ if (node.tagName === 'A' && !node.getAttribute('rel')?.includes('noopener')) {
5
+ node.setAttribute('rel', `${node.getAttribute('rel') ?? ''} noopener`.trim());
6
+ }
7
+});
8
+
9
export function sanitize(html: string | null) {
10
return html
11
? DOMPurify.sanitize(html, {
12
ADD_TAGS: ['iframe'],
13
+ ADD_ATTR: ['target'],
14
CUSTOM_ELEMENT_HANDLING: {
15
tagNameCheck: () => true,
16
attributeNameCheck: (name) => {
0 commit comments