mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-20 10:55:25 +00:00
fix(mail): Use text/plain fallback if an error occured while parsing html message
This commit is contained in:
@@ -179,8 +179,9 @@
|
||||
id info, viewer;
|
||||
NSArray *parts;
|
||||
NSMutableArray *renderedParts;
|
||||
NSString *preferredType;
|
||||
NSString *preferredType, *htmlNoTags;
|
||||
NSUInteger i, max;
|
||||
BOOL fallbackNeeded, hasTextPlain;
|
||||
|
||||
if ([self decodedFlatContent])
|
||||
parts = [[self decodedFlatContent] parts];
|
||||
@@ -214,6 +215,27 @@
|
||||
[[self childInfo] objectForKey: @"type"],
|
||||
[[self childInfo] objectForKey: @"subtype"]];
|
||||
|
||||
// Check if the HTML part is good
|
||||
// If no, try to fallback on text/plain
|
||||
fallbackNeeded = NO;
|
||||
hasTextPlain = NO;
|
||||
for (i = 0 ; i < [renderedParts length] ; i++) {
|
||||
if ([[[[renderedParts objectAtIndex: i] objectForKey: @"contentType"] lowercaseString] isEqualToString: @"text/html"]
|
||||
&& [[preferredType lowercaseString] isEqualToString: @"text/html"]) {
|
||||
if ([[renderedParts objectAtIndex: i] objectForKey:@"exception"]) {
|
||||
fallbackNeeded = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if ([[[[renderedParts objectAtIndex: i] objectForKey: @"contentType"] lowercaseString] isEqualToString: @"text/plain"]) {
|
||||
hasTextPlain = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (fallbackNeeded && hasTextPlain) {
|
||||
preferredType = @"text/plain";
|
||||
}
|
||||
|
||||
return [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[self className], @"type",
|
||||
preferredType, @"preferredPart",
|
||||
|
||||
Reference in New Issue
Block a user