Skip to content

Commit

Permalink
Fix rendering of forwarded HTML message with img
Browse files Browse the repository at this point in the history
Fixes #3981 (partially)
  • Loading branch information
cgx committed Jan 11, 2017
1 parent 589827a commit e5d0b0b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -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)
------------------

Expand Down
1 change: 1 addition & 0 deletions UI/MailPartViewers/UIxMailPartAlternativeViewer.m
Expand Up @@ -168,6 +168,7 @@ - (id) renderedPart {
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [self childPartPath]];
[viewer setAttachmentIds: attachmentIds];
[renderedParts addObject: [viewer renderedPart]];
}

Expand Down
7 changes: 3 additions & 4 deletions UI/MailPartViewers/UIxMailPartHTMLViewer.m
Expand Up @@ -609,8 +609,7 @@ - (void) startElement: (NSString *) _localName
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);
}
Expand Down Expand Up @@ -920,7 +919,7 @@ - (void) _parseContent
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
Expand Down Expand Up @@ -1047,7 +1046,7 @@ - (void) _parseContent
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
Expand Down
1 change: 1 addition & 0 deletions UI/MailPartViewers/UIxMailPartMixedViewer.m
Expand Up @@ -101,6 +101,7 @@ - (id) renderedPart {
viewer = [[[self context] mailRenderingContext] viewerForBodyInfo: info];
[viewer setBodyInfo: info];
[viewer setPartPath: [self childPartPath]];
[viewer setAttachmentIds: attachmentIds];
[renderedParts addObject: [viewer renderedPart]];
}
contentType = [NSString stringWithFormat: @"%@/%@",
Expand Down
4 changes: 4 additions & 0 deletions UI/MailPartViewers/UIxMailPartViewer.h
Expand Up @@ -45,6 +45,7 @@
@class NSArray;
@class NSData;
@class NSFormatter;
@class NSMutableDictionary;

@class SOGoMailBodyPart;

Expand All @@ -53,6 +54,7 @@
NSArray *partPath;
id bodyInfo;
NSData *flatContent;
NSDictionary *attachmentIds;
}

/* accessors */
Expand All @@ -66,6 +68,8 @@
- (SOGoMailBodyPart *) clientPart;
- (id) renderedPart;

- (void) setAttachmentIds: (NSDictionary *) newAttachmentIds;

- (NSData *)flatContent;
- (NSData *)decodedFlatContent;
- (NSString *)flatContentAsString;
Expand Down
15 changes: 15 additions & 0 deletions UI/MailPartViewers/UIxMailPartViewer.m
Expand Up @@ -42,6 +42,16 @@

@implementation UIxMailPartViewer

- (id) init
{
if ((self = [super init]))
{
attachmentIds = nil;
}

return self;
}

- (void) dealloc
{
[flatContent release];
Expand Down Expand Up @@ -153,6 +163,11 @@ - (id) renderedPart
nil];
}

- (void) setAttachmentIds: (NSDictionary *) newAttachmentIds
{
attachmentIds = newAttachmentIds;
}

- (NSData *) content
{
return [[self clientObject] fetchBLOB];
Expand Down
14 changes: 14 additions & 0 deletions UI/MailerUI/UIxMailView.m
Expand Up @@ -213,6 +213,20 @@ - (id) contentViewerComponent
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;
}

Expand Down

0 comments on commit e5d0b0b

Please sign in to comment.