From 4a4a14e8055a693137955806a0b0266f30c6848c Mon Sep 17 00:00:00 2001 From: Simon Bjerre Date: Sun, 19 Jan 2025 17:09:49 +0100 Subject: [PATCH] sanitizeHtml --- src/components/Announcements.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/Announcements.tsx b/src/components/Announcements.tsx index 6baa284..a767a61 100644 --- a/src/components/Announcements.tsx +++ b/src/components/Announcements.tsx @@ -41,6 +41,17 @@ async function AnnoucementPosts() { } var data = await AnnoucementPosts() +const sanitizeHtml = (html: any) => { + const parser = new DOMParser(); + const doc = parser.parseFromString(html, "text/html"); + + // Remove all tags + const images = doc.querySelectorAll("img"); + images.forEach((img) => img.remove()); + + return doc.body.innerHTML; +}; + const Annoucements = () => { return ( @@ -53,7 +64,7 @@ const Annoucements = () => {
{post.title}
-
+