From 863280d6ac54783a7fe6a8ce3fcdd8c3a4c4e4ff Mon Sep 17 00:00:00 2001 From: smizrahi Date: Fri, 10 May 2024 14:51:09 +0200 Subject: [PATCH] fix(mail): Remove some css when generating UIxMailPartHTMLViewer. Sometimes, the mail contains SOGo mail template in the content, and broke mail display. --- UI/MailPartViewers/UIxMailPartHTMLViewer.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/UI/MailPartViewers/UIxMailPartHTMLViewer.m b/UI/MailPartViewers/UIxMailPartHTMLViewer.m index 1bacd6ce3..07a36f446 100644 --- a/UI/MailPartViewers/UIxMailPartHTMLViewer.m +++ b/UI/MailPartViewers/UIxMailPartHTMLViewer.m @@ -109,6 +109,13 @@ _xmlCharsetForCharset (NSString *charset) return encoding; } +static NSString *_sanitizeHtmlForDisplay(NSString *content) +{ + // Sometimes, the mail contains SOGo mail template in the content, and broke mail display + // replace the responsible css + return [content stringByReplacingOccurrencesOfString: @"sg-face layout-fill layout-column" withString:@""];; +} + @interface _UIxHTMLMailContentHandler : NSObject { NSMutableString *result; @@ -912,8 +919,8 @@ _xmlCharsetForCharset (NSString *charset) { if (!handler) [self _parseContent]; - - return [handler result]; + + return _sanitizeHtmlForDisplay([handler result]); } @end @@ -1065,7 +1072,7 @@ _xmlCharsetForCharset (NSString *charset) if (!handler) [self _parseContent]; - return [handler result]; + return _sanitizeHtmlForDisplay([handler result]); } @end