From 0c6cae110fb7e9b5a26621b4b16147cb1953e24b Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Mon, 7 Jul 2025 19:53:50 +0200 Subject: [PATCH] feat: add more restrictions to markdown sanitization --- components/Message.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/Message.vue b/components/Message.vue index e8a91b5..c903012 100644 --- a/components/Message.vue +++ b/components/Message.vue @@ -60,7 +60,16 @@ const sanitized = ref(); onMounted(async () => { const parsed = await parse(props.text, { gfm: true }); - sanitized.value = DOMPurify.sanitize(parsed, { ALLOWED_TAGS: ["strong", "em", "br", "blockquote", "code", "ul", "ol", "li", "a", "h1", "h2", "h3", "h4", "h5", "h6"] }); + sanitized.value = DOMPurify.sanitize(parsed, { + ALLOWED_TAGS: [ + "strong", "em", "br", "blockquote", + "code", "ul", "ol", "li", "a", "h1", + "h2", "h3", "h4", "h5", "h6" + ], + ALLOW_DATA_ATTR: false, + ALLOW_SELF_CLOSE_IN_ATTR: false, + ALLOWED_ATTR: [] + }); console.log("adding listeners") await nextTick(); messageElement.value?.addEventListener("mouseenter", (e: Event) => {