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 b8df16c commit cb960fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -4,6 +4,9 @@
Enhancements
- [web] updated CKEditor to version 4.6.0

Bug fixes
- [web] restore attributes when rewriting base64-encoded img tags (#3814)

3.2.2 (2016-11-23)
------------------

Expand Down
17 changes: 15 additions & 2 deletions SoObjects/Mailer/NSString+Mail.m
Expand Up @@ -289,7 +289,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 @@ -344,8 +344,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 cb960fa

Please sign in to comment.