This commit is contained in:
1 parent
45c09064d3
commit
cfd41e2c83
1 file changed
+6
-6
@@ -90,13 +90,13 @@ export function sanitizeMarkdownHtml(html: string): string {
|
|||||||
},
|
},
|
||||||
transformTags: {
|
transformTags: {
|
||||||
a: (tagName, attribs) => {
|
a: (tagName, attribs) => {
|
||||||
if (attribs.target === '_blank') {
|
if (attribs['data-fancybox'] || (attribs.href && attribs.href.startsWith('#'))) {
|
||||||
const rel = new Set((attribs.rel || '').split(/\s+/).filter(Boolean));
|
return { tagName, attribs };
|
||||||
rel.add('noopener');
|
|
||||||
rel.add('noreferrer');
|
|
||||||
return { tagName, attribs: { ...attribs, rel: [...rel].join(' ') } };
|
|
||||||
}
|
}
|
||||||
return { tagName, attribs };
|
const rel = new Set((attribs.rel || '').split(/\s+/).filter(Boolean));
|
||||||
|
rel.add('noopener');
|
||||||
|
rel.add('noreferrer');
|
||||||
|
return { tagName, attribs: { ...attribs, target: '_blank', rel: [...rel].join(' ') } };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user