2005-07-11 Helge Hess <helge.hess@opengroupware.org>
+ * NGMime: added a safeguard for some edge case (v4.5.224)
+
* NGImap4: added NGImap4Connection, NGImap4ConnectionManager (v4.5.223)
2005-07-07 Helge Hess <helge.hess@opengroupware.org>
+2005-07-11 Helge Hess <helge.hess@opengroupware.org>
+
+ * NGMimeBodyGenerator.m: improved reliability against invalid body
+ objects
+
2005-04-24 Helge Hess <helge.hess@opengroupware.org>
* fixed gcc 4.0 warnings
id body;
encoding = [NSString defaultCStringEncoding];
- body = [_part body];
+ body = [_part body];
+ data = nil;
if ([body isKindOfClass:[NSString class]]) {
// TODO: deal with charset in content-type!
data = [body dataUsingEncoding:encoding];
}
- else
+ else if ([body respondsToSelector:@selector(bytes)])
data = body;
-#if 0
- else {
- NSLog(@"WARNING: textBodyGenerator expect that body is"
- @" kind of class NSString");
+ else if ([body respondsToSelector:@selector(dataUsingEncoding:)])
+ data = [body dataUsingEncoding:encoding];
+ else if (body != nil) {
+ [self logWithFormat:@"ERROR: unexpected part body: %@", body];
+ return nil;
}
-#endif
+
if (data == nil) {
- NSLog(@"WARNING(%s): generate empty body", __PRETTY_FUNCTION__);
+ [self logWithFormat:@"WARNING(%s): generate empty body",
+ __PRETTY_FUNCTION__];
data = [NSData data];
}
return [self encodeData:data forPart:_part additionalHeaders:_addHeaders];