From 71cb01d540ab7cbb1c088d2dfd602aed5cfac30b Mon Sep 17 00:00:00 2001 From: alma Date: Thu, 24 Apr 2025 16:27:59 +0200 Subject: [PATCH] mime change --- lib/mail-parser-wrapper.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/mail-parser-wrapper.ts b/lib/mail-parser-wrapper.ts index 63684246..fecb181b 100644 --- a/lib/mail-parser-wrapper.ts +++ b/lib/mail-parser-wrapper.ts @@ -1,13 +1,7 @@ -import { simpleParser, ParsedMail, Attachment, HeaderValue, AddressObject } from 'mailparser'; +'use client'; + import DOMPurify from 'dompurify'; -// Create a window object for DOMPurify -const window = new JSDOM('').window; -const purify = DOMPurify(window); - -// Check if we're in a browser environment -const isBrowser = typeof window !== 'undefined'; - export interface ParsedEmail { subject: string | null; from: string | null; @@ -52,7 +46,7 @@ export async function decodeEmail(emailContent: string): Promise { function cleanHtml(html: string): string { try { - return purify.sanitize(html, { + return DOMPurify.sanitize(html, { ALLOWED_TAGS: ['p', 'br', 'div', 'span', 'a', 'img', 'strong', 'em', 'u', 'ul', 'ol', 'li', 'blockquote', 'pre', 'code', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'], ALLOWED_ATTR: ['href', 'src', 'alt', 'title', 'class', 'style'], ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i