diff --git a/ChangeLog b/ChangeLog index 22dcaa134..795ee7ea2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2004-02-19 Richard Frith-Macdonald * Source/Additions/GSMime.m: added a couple of uuencoding methods. + Integrated (crudely) uuencoding/uudecoding support based on x-uuencode 2004-02-18 David Ayers diff --git a/Source/Additions/GSMime.m b/Source/Additions/GSMime.m index 42638e89b..ffde169d3 100644 --- a/Source/Additions/GSMime.m +++ b/Source/Additions/GSMime.m @@ -574,6 +574,27 @@ wordData(NSString *word) } @end +/** + * Inefficient ... copies data into output object and only performs + * the actual decoding at the end. + */ +@interface GSMimeUUCodingContext : GSMimeCodingContext +@end + +@implementation GSMimeUUCodingContext +- (BOOL) decodeData: (const void*)sData + length: (unsigned)length + intoData: (NSMutableData*)dData +{ + [super decodeData: sData length: length intoData: dData]; + + if ([self atEnd] == YES) + { + [dData setData: [GSMimeDocument decode: dData UUName: 0]]; + } + return YES; +} +@end @interface GSMimeParser (Private) @@ -649,6 +670,7 @@ wordData(NSString *word) * 7bit (no coding actually performed) * 8bit (no coding actually performed) * chunked (for HTTP/1.1) + * x-uuencode * * To add new coding schemes to the parser, you need to ovrride * this method to return a new coding context for your scheme @@ -698,6 +720,10 @@ wordData(NSString *word) { return AUTORELEASE([GSMimeChunkedDecoderContext new]); } + else if ([value isEqualToString: @"x-uuencode"] == YES) + { + return AUTORELEASE([GSMimeUUCodingContext new]); + } } NSLog(@"contextFor: - unknown header (%@) ... assumed binary encoding", name); @@ -4601,6 +4627,18 @@ static NSCharacterSet *tokenSet = nil; } [md appendBytes: &ptr[pos] length: len-pos]; } + else if ([[enc value] isEqualToString: @"x-uuencode"] == YES) + { + NSString *name; + + name = [[self headerNamed: @"content-type"] parameterForKey: @"name"]; + if (name == nil) + { + name = @"data"; + } + d = [GSMimeDocument encode: d UUName: name]; + [md appendData: d]; + } else { [md appendData: d];