From 75638580ffa390a5215a647071db1dc8428ea4d9 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Tue, 15 Sep 2009 11:51:08 +0000 Subject: [PATCH] Log excess data. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28686 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Headers/Additions/GNUstepBase/GSMime.h | 4 +++- Source/Additions/GSMime.m | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd6815d44..eef7f0a8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-09-15 Richard Frith-Macdonald + + * Headers/Additions/GNUstepBase/GSMime.h: + * Source/Additions/GSMime.m: + Add new -excess method to return any excess data left over from parsing. + Previously the code just used to NSLog() this data as a warning. + 2009-09-14 Richard Frith-Macdonald * Source/NSCalendarDate.m: Workaround for bug in some linux SMP systems diff --git a/Headers/Additions/GNUstepBase/GSMime.h b/Headers/Additions/GNUstepBase/GSMime.h index bd729e86c..b80f94823 100644 --- a/Headers/Additions/GNUstepBase/GSMime.h +++ b/Headers/Additions/GNUstepBase/GSMime.h @@ -202,8 +202,9 @@ extern "C" { unsigned int hadErrors:1; unsigned int buggyQuotes:1; unsigned int wantEndOfLine:1; + unsigned int excessData:1; } flags; - NSData *boundary; + NSData *boundary; // Also overloaded to hold excess GSMimeDocument *document; GSMimeParser *child; GSMimeCodingContext *context; @@ -219,6 +220,7 @@ extern "C" { fromRange: (NSRange)aRange intoData: (NSMutableData*)dData withContext: (GSMimeCodingContext*)con; +- (NSData*) excess; - (void) expectNoHeaders; - (BOOL) isComplete; - (BOOL) isHttp; diff --git a/Source/Additions/GSMime.m b/Source/Additions/GSMime.m index c5fa42a81..b5e59f8f2 100644 --- a/Source/Additions/GSMime.m +++ b/Source/Additions/GSMime.m @@ -1107,6 +1107,19 @@ wordData(NSString *word) return document; } +/** If there was more data passed to the parser than actually needed to + * form the document, this method returns that excess data, othrwise it + * returns nil. + */ +- (NSData*) excess +{ + if (flags.excessData == 1) + { + return boundary; + } + return nil; +} + /** * This method may be called to tell the parser that it should not expect * to parse any headers, and that the data it will receive is body data.
@@ -2401,7 +2414,8 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info); rawBodyLength = expect; excess = [d subdataWithRange: NSMakeRange(dLength, [d length] - dLength)]; - NSLog(@"Excess data ignored: %@", excess); + ASSIGN(boundary, excess); + flags.excessData = 1; } [self decodeData: d fromRange: NSMakeRange(0, dLength)