Skip to content

Commit

Permalink
Restore attributes of base64-encoded img tags
Browse files Browse the repository at this point in the history
Fixes #3814
  • Loading branch information
cgx committed Nov 23, 2016
1 parent 1ff24dd commit 3711e7d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion NEWS
@@ -1,5 +1,4 @@
2.3.18 (2016-11-DD)
-------------------

New features
- [eas] relaxed permission requirements for subscription synchronizations (#3118 and #3180)
Expand All @@ -17,6 +16,7 @@ Bug fixes
- [web] fixed support for recurrent tasks
- [web] improved validation of mail account delegators
- [web] allow edition of a mailbox rights when user can administer mailbox
- [web] restore attributes when rewriting base64-encoded img tags (#3814)

2.3.17 (2016-10-20)
-------------------
Expand Down
17 changes: 15 additions & 2 deletions SoObjects/Mailer/NSString+Mail.m
Expand Up @@ -296,7 +296,7 @@ - (void) startElement: (NSString *) element
//
if ([value length] > 5 && [[value substringToIndex: 5] caseInsensitiveCompare: @"data:"] == NSOrderedSame)
{
NSString *uniqueId, *mimeType, *encoding;
NSString *uniqueId, *mimeType, *encoding, *attrName;
NGMimeBodyPart *bodyPart;
NGMutableHashMap *map;
NSData *data;
Expand Down Expand Up @@ -351,8 +351,21 @@ - (void) startElement: (NSString *) element
[body release];

[images addObject: bodyPart];

[result appendFormat: @"<img src=\"cid:%@\" type=\"%@\"", uniqueId, mimeType];

// Restore img attributes
for (i = 0; i < [attributes count]; i++)
{
attrName = [[attributes rawNameAtIndex: i] lowercaseString];
if (![attrName isEqualToString: @"src"] && ![attrName isEqualToString: @"type"])
{
value = [attributes valueAtIndex: i];
[result appendFormat: @" %@=\"%@\"", attrName, value];
}
}

[result appendFormat: @"<img src=\"cid:%@\" type=\"%@\"/>", uniqueId, mimeType];
[result appendString: @"/>"];
}
}
else if (voidTags)
Expand Down

0 comments on commit 3711e7d

Please sign in to comment.