fix problem font in detail email + refetch inbox when open detail email + ...
This commit is contained in:
@@ -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 "خطا در نمایش محتوای ایمیل";
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user