From a5a2b746ad2d8bd99d0543ba10ef63a86d7f39fb Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Thu, 15 Jun 2006 14:05:22 +0000 Subject: [PATCH] Minor tidyup git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23064 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 ++++- Source/Additions/GSMime.m | 31 ++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index adb6621ec..1dbc6e6cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,10 @@ * Additions/GNUstepBase/GSXML.h: New XMLRPC settings to control timezone and to produce compact output. * Source/Additions/GSXML.m: New methods and bugfix for handling - strng data with no 'string' element markup. + string data with no 'string' element markup. + * Additions/GNUstepBase/GSMime.h: Fix possible cases of parsing + saying that it needs more data when you have passed it an empty + data item to terminate parsing. 2006-06-06 Richard Frith-Macdonald diff --git a/Source/Additions/GSMime.m b/Source/Additions/GSMime.m index 1546c1e1c..bae478319 100644 --- a/Source/Additions/GSMime.m +++ b/Source/Additions/GSMime.m @@ -1472,15 +1472,13 @@ wordData(NSString *word) } else { - BOOL result; - if (flags.wantEndOfLine == 1) { - result = [self parse: [NSData dataWithBytes: "\r\n" length: 2]]; + [self parse: [NSData dataWithBytes: "\r\n" length: 2]]; } else if (flags.inBody == 1) { - result = [self _decodeBody: d]; + [self _decodeBody: d]; } else { @@ -1488,12 +1486,12 @@ wordData(NSString *word) * If still parsing headers, add CR-LF sequences to terminate * the headers. */ - result = [self parse: [NSData dataWithBytes: "\r\n\r\n" length: 4]]; + [self parse: [NSData dataWithBytes: "\r\n\r\n" length: 4]]; } flags.wantEndOfLine = 0; flags.inBody = 0; flags.complete = 1; /* Finished parsing */ - return result; + return NO; /* Want no more data */ } } @@ -1684,21 +1682,24 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info); /** *

* This method is called to parse a header line and split its - * contents into an info dictionary. + * contents into the supplied [GSMimeHeader] instance. *

*

- * On entry, the dictionary is already partially filled, - * the name argument is a lowercase representation of the - * header name, and the scanner is set to a scan location - * immediately after the colon in the header string. + * On entry, the header (info) is already partially filled, + * the name is a lowercase representation of the + * header name. The the scanner must be set to a scan location + * immediately after the colon in the original header string + * (ie to the header value string). *

*

* If the header is parsed successfully, the method should * return YES, otherwise NO. *

*

- * You should not call this method directly yourself, but may - * override it to support parsing of new headers. + * You would not normally call this method directly yourself, + * but may override it to support parsing of new headers.
+ * If you do call this yourself, you need to be aware that it + * may change the state of the document in the parser. *

*

* You should be aware of the parsing that the standard @@ -2328,6 +2329,10 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info); return hdr; } +/* + * Return YES if more data is needed, NO if the body has been completely + * parsed. + */ - (BOOL) _decodeBody: (NSData*)d { unsigned l = [d length];