fix problem font in detail email + refetch inbox when open detail email + ...

This commit is contained in:
hamid zarghami
2025-07-17 12:46:16 +03:30
parent a8b203f324
commit 1139df424f
5 changed files with 102 additions and 9 deletions
+31
View File
@@ -80,3 +80,34 @@ export const formatDate = (dateString: string) => {
minute: "2-digit",
}).format(date);
};
export const sanitizeEmailHTML = (html: string): string => {
try {
// Remove style tags and their content
let sanitized = html.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "");
// Remove link tags (CSS files)
sanitized = sanitized.replace(/<link[^>]*>/gi, "");
// Remove all style attributes
sanitized = sanitized.replace(/\s*style\s*=\s*["'][^"']*["']/gi, "");
// Remove font-family and other font-related CSS properties
sanitized = sanitized
.replace(/font-family\s*:\s*[^;]*;?/gi, "")
.replace(/font-size\s*:\s*[^;]*;?/gi, "")
.replace(/font-weight\s*:\s*[^;]*;?/gi, "")
.replace(/color\s*:\s*[^;]*;?/gi, "");
// Remove script tags for security
sanitized = sanitized.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "");
// Remove potentially harmful attributes
sanitized = sanitized.replace(/\s*on\w+\s*=\s*["'][^"']*["']/gi, "");
return sanitized;
} catch (error) {
console.error("خطا در پاک‌سازی HTML:", error);
return "خطا در نمایش محتوای ایمیل";
}
};