Fix rendering of forwarded HTML message with img

Fixes #3981 (partially)
pull/232/head
Francis Lachapelle 2017-01-11 16:08:05 -05:00
parent 589827a414
commit e5d0b0b0ca
7 changed files with 41 additions and 4 deletions

3
NEWS
View File

@ -4,6 +4,9 @@
Enhancements
- [web] show locale codes beside language names in Preferences module
Bug fixes
- [web] fixed rendering of forwared HTML message with inline images (#3981)
3.2.5 (2017-01-10)
------------------

View File

@ -168,6 +168,7 @@
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [self childPartPath]];
[viewer setAttachmentIds: attachmentIds];
[renderedParts addObject: [viewer renderedPart]];
}

View File

@ -609,8 +609,7 @@ static NSData* _sanitizeContent(NSData *theData)
value = [_attributes valueAtIndex: count];
if ([value hasPrefix: @"cid:"])
{
cid = [NSString stringWithFormat: @"<%@>",
[value substringFromIndex: 4]];
cid = [value substringFromIndex: 4];
value = [attachmentIds objectForKey: cid];
skipAttribute = (value == nil);
}
@ -920,7 +919,7 @@ static NSData* _sanitizeContent(NSData *theData)
createXMLReaderForMimeType: @"text/html"];
handler = [_UIxHTMLMailContentHandler new];
[handler setAttachmentIds: [mail fetchFileAttachmentIds]];
[handler setAttachmentIds: attachmentIds];
// We check if we got an unsupported charset. If so
// we convert everything to UTF-16{LE,BE} so it passes
@ -1047,7 +1046,7 @@ static NSData* _sanitizeContent(NSData *theData)
encoding = @"us-ascii";
handler = [_UIxHTMLMailContentHandler new];
[handler setAttachmentIds: [mail fetchFileAttachmentIds]];
[handler setAttachmentIds: attachmentIds];
// We check if we got an unsupported charset. If so
// we convert everything to UTF-16{LE,BE} so it passes

View File

@ -101,6 +101,7 @@
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [self childPartPath]];
[viewer setAttachmentIds: attachmentIds];
[renderedParts addObject: [viewer renderedPart]];
}
contentType = [NSString stringWithFormat: @"%@/%@",

View File

@ -45,6 +45,7 @@
@class NSArray;
@class NSData;
@class NSFormatter;
@class NSMutableDictionary;
@class SOGoMailBodyPart;
@ -53,6 +54,7 @@
NSArray *partPath;
id bodyInfo;
NSData *flatContent;
NSDictionary *attachmentIds;
}
/* accessors */
@ -66,6 +68,8 @@
- (SOGoMailBodyPart *) clientPart;
- (id) renderedPart;
- (void) setAttachmentIds: (NSDictionary *) newAttachmentIds;
- (NSData *)flatContent;
- (NSData *)decodedFlatContent;
- (NSString *)flatContentAsString;

View File

@ -42,6 +42,16 @@
@implementation UIxMailPartViewer
- (id) init
{
if ((self = [super init]))
{
attachmentIds = nil;
}
return self;
}
- (void) dealloc
{
[flatContent release];
@ -153,6 +163,11 @@
nil];
}
- (void) setAttachmentIds: (NSDictionary *) newAttachmentIds
{
attachmentIds = newAttachmentIds;
}
- (NSData *) content
{
return [[self clientObject] fetchBLOB];

View File

@ -213,6 +213,20 @@ static NSString *mailETag = nil;
viewer = [[context mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
NSMutableDictionary *attachmentIds;
NSDictionary *attributes;
unsigned int count, max;
max = [[self attachmentAttrs] count];
attachmentIds = [NSMutableDictionary dictionaryWithCapacity: max];
for (count = 0; count < max; count++)
{
attributes = [[self attachmentAttrs] objectAtIndex: count];
[attachmentIds setObject: [attributes objectForKey: @"url"]
forKey: [attributes objectForKey: @"filename"]];
}
[viewer setAttachmentIds: attachmentIds];
return viewer;
}