mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-24 19:58:54 +00:00
oc-mail: Better management of nested multipart types
Instead of treating all the message either as alternative or mixed with this changeset the MIME type of the parent part is used. This allows a correct disposition of the message in the cases when nested multiparts elements are used. Also in mixed parts we convert between plain text and HTML as needed.
This commit is contained in:
1 parent
e1b1812364
commit
f388d180ae
4 files changed
+93
-43
No files matched your search
@@ -516,12 +516,15 @@ static BOOL debugSoParts = NO;
|
||||
return s;
|
||||
}
|
||||
|
||||
/* This is defined before the public version without parentMimeType
|
||||
argument to be able to call it recursively */
|
||||
/* bulk fetching of plain/text content */
|
||||
- (void) addRequiredKeysOfStructure: (NSDictionary *) info
|
||||
path: (NSString *) p
|
||||
toArray: (NSMutableArray *) keys
|
||||
acceptedTypes: (NSArray *) types
|
||||
path: (NSString *) p
|
||||
toArray: (NSMutableArray *) keys
|
||||
acceptedTypes: (NSArray *) types
|
||||
withPeek: (BOOL) withPeek
|
||||
parentMultipart: (NSString *) parentMPart
|
||||
{
|
||||
/*
|
||||
This is used to collect the set of IMAP4 fetch-keys required to fetch
|
||||
@@ -536,6 +539,7 @@ static BOOL debugSoParts = NO;
|
||||
id body;
|
||||
NSString *bodyToken, *sp, *mimeType;
|
||||
id childInfo;
|
||||
NSString *multipart;
|
||||
|
||||
bodyToken = (withPeek ? @"body.peek" : @"body");
|
||||
|
||||
@@ -543,6 +547,12 @@ static BOOL debugSoParts = NO;
|
||||
[info valueForKey: @"type"],
|
||||
[info valueForKey: @"subtype"]]
|
||||
lowercaseString];
|
||||
|
||||
if ([[info valueForKey: @"type"] isEqualToString: @"multipart"])
|
||||
multipart = mimeType;
|
||||
else
|
||||
multipart = parentMPart;
|
||||
|
||||
if ([types containsObject: mimeType])
|
||||
{
|
||||
if ([p length] > 0)
|
||||
@@ -557,7 +567,8 @@ static BOOL debugSoParts = NO;
|
||||
k = [NSString stringWithFormat: @"%@[text]", bodyToken];
|
||||
}
|
||||
[keys addObject: [NSDictionary dictionaryWithObjectsAndKeys: k, @"key",
|
||||
mimeType, @"mimeType", nil]];
|
||||
mimeType, @"mimeType",
|
||||
multipart, @"multipart", nil]];
|
||||
}
|
||||
|
||||
parts = [info objectForKey: @"parts"];
|
||||
@@ -571,9 +582,11 @@ static BOOL debugSoParts = NO;
|
||||
childInfo = [parts objectAtIndex: i];
|
||||
|
||||
[self addRequiredKeysOfStructure: childInfo
|
||||
path: sp toArray: keys
|
||||
acceptedTypes: types
|
||||
withPeek: withPeek];
|
||||
path: sp
|
||||
toArray: keys
|
||||
acceptedTypes: types
|
||||
withPeek: withPeek
|
||||
parentMultipart: multipart];
|
||||
}
|
||||
|
||||
/* check body */
|
||||
@@ -597,12 +610,28 @@ static BOOL debugSoParts = NO;
|
||||
else
|
||||
sp = [p length] > 0 ? (id)[p stringByAppendingString: @".1"] : (id)@"1";
|
||||
[self addRequiredKeysOfStructure: body
|
||||
path: sp toArray: keys
|
||||
acceptedTypes: types
|
||||
withPeek: withPeek];
|
||||
path: sp
|
||||
toArray: keys
|
||||
acceptedTypes: types
|
||||
withPeek: withPeek
|
||||
parentMultipart: multipart];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) addRequiredKeysOfStructure: (NSDictionary *) info
|
||||
path: (NSString *) p
|
||||
toArray: (NSMutableArray *) keys
|
||||
acceptedTypes: (NSArray *) types
|
||||
withPeek: (BOOL) withPeek
|
||||
{
|
||||
[self addRequiredKeysOfStructure: (NSDictionary *) info
|
||||
path: (NSString *) p
|
||||
toArray: (NSMutableArray *) keys
|
||||
acceptedTypes: (NSArray *) types
|
||||
withPeek: (BOOL) withPeek
|
||||
parentMultipart: @""];
|
||||
}
|
||||
|
||||
- (NSArray *) plainTextContentFetchKeys
|
||||
{
|
||||
/*
|
||||
|
||||
Reference in new issue
Block a user