From 32ec0d2472d89d6b5c5920df364b0ace547c13a0 Mon Sep 17 00:00:00 2001
From: Claire <claire.github-309c@sitedethib.com>
Date: Sat, 24 Jun 2023 17:24:31 +0200
Subject: [PATCH] [Glitch] Fix verified badge in account lists potentially
 including rel="me" links

Port 55e7c08a83547424024bac311d5459cb82cf6dae to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
---
 .../glitch/components/verified_badge.tsx       | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/app/javascript/flavours/glitch/components/verified_badge.tsx b/app/javascript/flavours/glitch/components/verified_badge.tsx
index 6b421ba42c..9a6adcfa86 100644
--- a/app/javascript/flavours/glitch/components/verified_badge.tsx
+++ b/app/javascript/flavours/glitch/components/verified_badge.tsx
@@ -1,11 +1,27 @@
 import { Icon } from './icon';
 
+const domParser = new DOMParser();
+
+const stripRelMe = (html: string) => {
+  const document = domParser.parseFromString(html, 'text/html').documentElement;
+
+  document.querySelectorAll<HTMLAnchorElement>('a[rel]').forEach((link) => {
+    link.rel = link.rel
+      .split(' ')
+      .filter((x: string) => x !== 'me')
+      .join(' ');
+  });
+
+  const body = document.querySelector('body');
+  return body ? { __html: body.innerHTML } : undefined;
+};
+
 interface Props {
   link: string;
 }
 export const VerifiedBadge: React.FC<Props> = ({ link }) => (
   <span className='verified-badge'>
     <Icon id='check' className='verified-badge__mark' />
-    <span dangerouslySetInnerHTML={{ __html: link }} />
+    <span dangerouslySetInnerHTML={stripRelMe(link)} />
   </span>
 );