From f8ff98b657b61408208f7a14632bb323dec32a49 Mon Sep 17 00:00:00 2001 From: Hivert Quentin Date: Tue, 4 Feb 2025 15:28:19 +0100 Subject: [PATCH] fix(htmlViewer): if the the tag img is not a url but a base64 image, keep it in the preview --- UI/MailPartViewers/UIxMailPartHTMLViewer.m | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/UI/MailPartViewers/UIxMailPartHTMLViewer.m b/UI/MailPartViewers/UIxMailPartHTMLViewer.m index 1930ad8c3..5f5960310 100644 --- a/UI/MailPartViewers/UIxMailPartHTMLViewer.m +++ b/UI/MailPartViewers/UIxMailPartHTMLViewer.m @@ -521,7 +521,25 @@ static NSString *_sanitizeHtmlForDisplay(NSString *content) { /* [resultPart appendString: @"src=\"/SOGo.woa/WebServerResources/empty.gif\""]; */ - name = @"unsafe-src"; + + //Check if the image is base64 ant not url + NSUInteger i, c; + BOOL isBase64 = NO; + for (i = 0, c = [_attributes count]; i < c; i++) { + NSString *type, *value; + type = [_attributes nameAtIndex:i]; + if ([type isEqualToString:@"src"]) + { + value = [_attributes valueAtIndex:i]; + if([value length] > 4 && [[value substringToIndex: 4] isEqualToString:@"data"]) + { + isBase64 = YES; + break; + } + } + } + if(!isBase64) + name = @"unsafe-src"; } else skipAttribute = YES;