diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index b46f7097..280d78a8 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -413,11 +413,76 @@ function decodeMimeContent(content: string): string { // Add this helper function const renderEmailContent = (email: Email) => { - const decodedContent = decodeMimeContent(email.body); - if (email.body.includes('Content-Type: text/html')) { - return
; + try { + // First try to decode the MIME content + const decodedContent = decodeMimeContent(email.body); + + // Check if the content is HTML + const isHtml = decodedContent.includes('<') && + (decodedContent.includes(']*>([\s\S]*?)<\/body>/i); + const content = bodyMatch ? bodyMatch[1] : decodedContent; + + // Sanitize HTML content + const sanitizedHtml = content + .replace(/