mime change

This commit is contained in:
alma 2025-04-24 16:27:59 +02:00
parent 9e379f1c8a
commit 71cb01d540

View File

@ -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<ParsedEmail> {
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