mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 09:41:15 +00:00
Take note of errors when parsing, and refrain from making the parse
operation complete. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13724 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
41d0a79f08
commit
f2ba0022d6
2 changed files with 22 additions and 3 deletions
|
@ -127,6 +127,7 @@
|
||||||
BOOL inBody;
|
BOOL inBody;
|
||||||
BOOL isHttp;
|
BOOL isHttp;
|
||||||
BOOL complete;
|
BOOL complete;
|
||||||
|
BOOL hadErrors;
|
||||||
NSData *boundary;
|
NSData *boundary;
|
||||||
GSMimeDocument *document;
|
GSMimeDocument *document;
|
||||||
GSMimeParser *child;
|
GSMimeParser *child;
|
||||||
|
|
|
@ -813,6 +813,7 @@ parseCharacterSet(NSString *token)
|
||||||
}
|
}
|
||||||
if ([self parseHeader: header] == NO)
|
if ([self parseHeader: header] == NO)
|
||||||
{
|
{
|
||||||
|
hadErrors = YES;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -891,10 +892,16 @@ parseCharacterSet(NSString *token)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns YES if the document parsing is known to be completed.
|
* Returns YES if the document parsing is known to be completed successfully.
|
||||||
|
* Returns NO if either more data is needed, or if the parser encountered an
|
||||||
|
* error.
|
||||||
*/
|
*/
|
||||||
- (BOOL) isComplete
|
- (BOOL) isComplete
|
||||||
{
|
{
|
||||||
|
if (hadErrors == YES)
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,6 +972,12 @@ parseCharacterSet(NSString *token)
|
||||||
* is complete.
|
* is complete.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
|
* The parser attempts to be as flexible as possible and to continue
|
||||||
|
* parsing wherever it can. If an error occurs in parsing, the
|
||||||
|
* -isComplete method will always return NO, even after the -parse:
|
||||||
|
* method has been called with a nil argument.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
* A multipart document will be parsed to content consisting of an
|
* A multipart document will be parsed to content consisting of an
|
||||||
* NSArray of GSMimeDocument instances representing each part.<br />
|
* NSArray of GSMimeDocument instances representing each part.<br />
|
||||||
* Otherwise, a document will become content of type NSData, unless
|
* Otherwise, a document will become content of type NSData, unless
|
||||||
|
@ -1009,6 +1022,7 @@ parseCharacterSet(NSString *token)
|
||||||
}
|
}
|
||||||
if ([self parseHeader: header] == NO)
|
if ([self parseHeader: header] == NO)
|
||||||
{
|
{
|
||||||
|
hadErrors = YES;
|
||||||
return NO; /* Header not parsed properly. */
|
return NO; /* Header not parsed properly. */
|
||||||
}
|
}
|
||||||
NSDebugMLLog(@"GSMime", @"Parsed header '%@'", header);
|
NSDebugMLLog(@"GSMime", @"Parsed header '%@'", header);
|
||||||
|
@ -2049,9 +2063,13 @@ parseCharacterSet(NSString *token)
|
||||||
endedFinalPart = YES;
|
endedFinalPart = YES;
|
||||||
}
|
}
|
||||||
if (bytes[sectionStart] == '\r')
|
if (bytes[sectionStart] == '\r')
|
||||||
|
{
|
||||||
sectionStart++;
|
sectionStart++;
|
||||||
|
}
|
||||||
if (bytes[sectionStart] == '\n')
|
if (bytes[sectionStart] == '\n')
|
||||||
|
{
|
||||||
sectionStart++;
|
sectionStart++;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create data object for this section and pass it to the
|
* Create data object for this section and pass it to the
|
||||||
|
|
Loading…
Reference in a new issue