fix(htmlViewer): if the the tag img is not a url but a base64 image, keep it in the preview

This commit is contained in:
Hivert Quentin
2025-02-04 15:28:19 +01:00
parent 512f14f6d0
commit f8ff98b657

View File

@@ -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;