fix(mail): Fix inline text issue when Hide inline attachment option is set

This commit is contained in:
smizrahi
2024-01-03 09:10:48 +01:00
parent 5ad1d9d9c3
commit 00d69560ba
4 changed files with 25 additions and 15 deletions

View File

@@ -124,21 +124,18 @@
info = [self childInfo];
ud = [[[self context] activeUser] userDefaults];
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [self childPartPath]];
if ([self decodedFlatContent])
[viewer setDecodedContent: [parts objectAtIndex: i]];
[viewer setAttachmentIds: attachmentIds
displayAttachment:!([info objectForKey:@"disposition"]
&& [[info objectForKey:@"disposition"] objectForKey:@"type"]
&& [[[[info objectForKey:@"disposition"] objectForKey:@"type"] uppercaseString] isEqualToString:@"INLINE"]
&& [ud hideInlineAttachments])];
if (!([info objectForKey:@"disposition"]
&& [[info objectForKey:@"disposition"] objectForKey:@"type"]
&& [[[[info objectForKey:@"disposition"] objectForKey:@"type"] uppercaseString] isEqualToString:@"INLINE"]
&& [ud hideInlineAttachments])) {
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [self childPartPath]];
if ([self decodedFlatContent])
[viewer setDecodedContent: [parts objectAtIndex: i]];
[viewer setAttachmentIds: attachmentIds];
[renderedParts addObject: [viewer renderedPart]];
}
[renderedParts addObject: [viewer renderedPart]];
}
contentType = [NSString stringWithFormat: @"%@/%@",

View File

@@ -46,6 +46,7 @@
@class NSData;
@class NSFormatter;
@class NSMutableDictionary;
@class NSNumber;
@class SOGoMailBodyPart;
@@ -56,6 +57,7 @@
NSData *flatContent;
id decodedContent;
NSDictionary *attachmentIds;
BOOL _shouldDisplayAttachment;
}
/* accessors */
@@ -71,6 +73,7 @@
- (NSDictionary *) attachmentIds;
- (void) setAttachmentIds: (NSDictionary *) newAttachmentIds;
- (void) setAttachmentIds:(NSDictionary *)newAttachmentIds displayAttachment:(BOOL)shouldDisplayAttachment;
- (NSData *)flatContent;
- (void) setFlatContent: (NSData *) theData;

View File

@@ -54,6 +54,7 @@
attachmentIds = nil;
flatContent = nil;
decodedContent = nil;
_shouldDisplayAttachment = YES;
}
return self;
@@ -204,6 +205,7 @@
[[self sizeFormatter] stringForObjectValue: [bodyInfo objectForKey: @"size"]], @"size",
[self pathToAttachment], @"viewURL",
[self pathForDownload], @"downloadURL",
[NSNumber numberWithBool:_shouldDisplayAttachment], @"shouldDisplayAttachment",
nil];
}
@@ -222,6 +224,12 @@
attachmentIds = newAttachmentIds;
}
- (void) setAttachmentIds:(NSDictionary *)newAttachmentIds displayAttachment:(BOOL)shouldDisplayAttachment
{
[self setAttachmentIds: newAttachmentIds];
_shouldDisplayAttachment = shouldDisplayAttachment;
}
- (NSString *) flatContentAsString
{
NSString *charset, *s;

View File

@@ -461,7 +461,9 @@
// Trusted content that can be compiled (Angularly-speaking)
part.compile = true;
parts.push(part);
if (!Object.hasOwn(part, 'shouldDisplayAttachment') || 1 == part.shouldDisplayAttachment ) {
parts.push(part);
}
}
else {
part.html = true;