diff --git a/Headers/Additions/GNUstepBase/GSMime.h b/Headers/Additions/GNUstepBase/GSMime.h index b80f94823..1c7a02c83 100644 --- a/Headers/Additions/GNUstepBase/GSMime.h +++ b/Headers/Additions/GNUstepBase/GSMime.h @@ -203,6 +203,7 @@ extern "C" { unsigned int buggyQuotes:1; unsigned int wantEndOfLine:1; unsigned int excessData:1; + unsigned int headersOnly:1; } flags; NSData *boundary; // Also overloaded to hold excess GSMimeDocument *document; @@ -237,6 +238,7 @@ extern "C" { - (NSString*) scanToken: (NSScanner*)scanner; - (void) setBuggyQuotes: (BOOL)flag; - (void) setDefaultCharset: (NSString*)aName; +- (void) setHeadersOnly; - (void) setIsHttp; @end diff --git a/Source/Additions/GSMime.m b/Source/Additions/GSMime.m index b5e59f8f2..211ab5435 100644 --- a/Source/Additions/GSMime.m +++ b/Source/Additions/GSMime.m @@ -1416,12 +1416,21 @@ wordData(NSString *word) * If there is a zero content length, all parsing is complete, * not just header parsing. */ - hdr = [document headerNamed: @"content-length"]; - if (hdr != nil && [[hdr value] intValue] == 0) + if (flags.headersOnly == 1 + || ((hdr = [document headerNamed: @"content-length"]) != nil + && [[hdr value] intValue] == 0)) { [document setContent: @""]; flags.inBody = 0; flags.complete = 1; + /* If we have more data after the headers ... it's excess and + * should become available as excess data. + */ + if ([d length] > 0) + { + ASSIGNCOPY(boundary, d); + flags.excessData = 1; + } } return NO; // No more data needed @@ -2093,6 +2102,14 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info); } } +/** + * Method to inform the parser that only the headers should be parsed + * and any remaining data be treated as excess + */ +- (void) setHeadersOnly +{ + flags.headersOnly = 1; +} /** * Method to inform the parser that the data it is parsing is an HTTP