From 59d48cb38285ab019013972baa3e5269b6188a5e Mon Sep 17 00:00:00 2001 From: smizrahi Date: Fri, 13 Sep 2024 15:53:53 +0200 Subject: [PATCH] fix(mail): Fix assertion when there is an empty image in the mail. Fixes #6035. --- UI/MailerUI/UIxMailEditor.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/UI/MailerUI/UIxMailEditor.m b/UI/MailerUI/UIxMailEditor.m index 4464ab403..1794dcdcf 100644 --- a/UI/MailerUI/UIxMailEditor.m +++ b/UI/MailerUI/UIxMailEditor.m @@ -722,12 +722,14 @@ static NSArray *infoKeys = nil; if ([[mime encoding] isEqualToString: @"base64"] && contentId) { if ([text rangeOfString: contentId].location != NSNotFound) { - lText = [text stringByReplacingOccurrencesOfString: contentId + if (nil != [[mime body] bytes]) { + lText = [text stringByReplacingOccurrencesOfString: contentId withString: [NSString stringWithFormat: @"data:%@;base64,%@", [[mime contentType] stringValue], [NSString stringWithUTF8String: [[mime body] bytes]]]]; - [self setText: lText]; - [draft deleteAttachmentWithName: [draftFileAttachement objectForKey:@"filename"]]; + [self setText: lText]; + [draft deleteAttachmentWithName: [draftFileAttachement objectForKey:@"filename"]]; + } } else { // This is an attachment with no CID in message body if ([draft inReplyTo]) {