Restore attributes of base64-encoded img tags

Fixes #3814
pull/226/head
Francis Lachapelle 2016-11-23 14:57:24 -05:00
parent b8df16cd8c
commit cb960fae02
2 changed files with 18 additions and 2 deletions

3
NEWS
View File

@ -4,6 +4,9 @@
Enhancements Enhancements
- [web] updated CKEditor to version 4.6.0 - [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) 3.2.2 (2016-11-23)
------------------ ------------------

View File

@ -289,7 +289,7 @@
// //
if ([value length] > 5 && [[value substringToIndex: 5] caseInsensitiveCompare: @"data:"] == NSOrderedSame) if ([value length] > 5 && [[value substringToIndex: 5] caseInsensitiveCompare: @"data:"] == NSOrderedSame)
{ {
NSString *uniqueId, *mimeType, *encoding; NSString *uniqueId, *mimeType, *encoding, *attrName;
NGMimeBodyPart *bodyPart; NGMimeBodyPart *bodyPart;
NGMutableHashMap *map; NGMutableHashMap *map;
NSData *data; NSData *data;
@ -344,8 +344,21 @@
[body release]; [body release];
[images addObject: bodyPart]; [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) else if (voidTags)