diff --git a/apps/meteor/client/components/MarkdownText.tsx b/apps/meteor/client/components/MarkdownText.tsx
index 191f72c8d6900..a5591227aad9a 100644
--- a/apps/meteor/client/components/MarkdownText.tsx
+++ b/apps/meteor/client/components/MarkdownText.tsx
@@ -26,7 +26,7 @@ marked.Lexer.rules.gfm = {
};
const linkMarked = (href: string | null, _title: string | null, text: string): string =>
- `${text} `;
+ `${text} `;
const paragraphMarked = (text: string): string => text;
const brMarked = (): string => ' ';
const listItemMarked = (text: string): string => {
@@ -46,6 +46,9 @@ inlineRenderer.hr = horizontalRuleMarked;
inlineWithoutBreaks.link = linkMarked;
inlineWithoutBreaks.paragraph = paragraphMarked;
inlineWithoutBreaks.br = brMarked;
+inlineWithoutBreaks.image = brMarked;
+inlineWithoutBreaks.code = paragraphMarked;
+inlineWithoutBreaks.codespan = paragraphMarked;
inlineWithoutBreaks.listitem = listItemMarked;
inlineWithoutBreaks.hr = horizontalRuleMarked;
@@ -118,6 +121,15 @@ const MarkdownText: FC> = ({
}
})();
+ // Add a hook to make all links open a new window
+ dompurify.addHook('afterSanitizeAttributes', (node) => {
+ // set all elements owning target to target=_blank
+ if ('target' in node) {
+ node.setAttribute('target', '_blank');
+ node.setAttribute('rel', 'nofollow noopener noreferrer');
+ }
+ });
+
return preserveHtml ? html : html && sanitizer(html, { ADD_ATTR: ['target'], ALLOWED_URI_REGEXP: getRegexp(schemes) });
}, [preserveHtml, sanitizer, content, variant, markedOptions, parseEmoji, schemes]);
diff --git a/apps/meteor/client/views/room/Announcement/Announcement.tsx b/apps/meteor/client/views/room/Announcement/Announcement.tsx
index 8134e4aa2d47a..052aabfa2f556 100644
--- a/apps/meteor/client/views/room/Announcement/Announcement.tsx
+++ b/apps/meteor/client/views/room/Announcement/Announcement.tsx
@@ -31,7 +31,7 @@ const Announcement: FC = ({ announcement, announcementDetail
: setModal(
-
+
,
);
@@ -39,7 +39,7 @@ const Announcement: FC = ({ announcement, announcementDetail
return announcement ? (
): void => handleClick(e)}>
-
+
) : null;
};