fix: Handle unsanitized markup in DOM (#4110)
This commit is contained in:
parent
e730804b48
commit
dd1fe4f93a
2 changed files with 18 additions and 3 deletions
|
@ -47,7 +47,12 @@ class MessageFormatter {
|
|||
const markedDownOutput = marked(withHash);
|
||||
return markedDownOutput;
|
||||
}
|
||||
return marked(this.message, { breaks: true, gfm: true });
|
||||
DOMPurify.addHook('afterSanitizeAttributes', node => {
|
||||
if ('target' in node) node.setAttribute('target', '_blank');
|
||||
});
|
||||
return DOMPurify.sanitize(
|
||||
marked(this.message, { breaks: true, gfm: true })
|
||||
);
|
||||
}
|
||||
|
||||
get formattedMessage() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue