mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
Make parsing more tolerant.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14903 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e597acb778
commit
0836f07632
2 changed files with 20 additions and 5 deletions
|
@ -7,6 +7,8 @@
|
||||||
* Source/NSDate.m: Update to use NSTimeIntervalSince1970
|
* Source/NSDate.m: Update to use NSTimeIntervalSince1970
|
||||||
* Source/NSTimer.m: Declare GSTimeNow() locally
|
* Source/NSTimer.m: Declare GSTimeNow() locally
|
||||||
* Source/NSprocessInfo.m: ditto
|
* Source/NSprocessInfo.m: ditto
|
||||||
|
* Source/Additions/GSMime.m: more tolerant parsing ... ignore excess
|
||||||
|
data in multi-part document.
|
||||||
|
|
||||||
Thu Oct 31 00:46:23 2002 Nicola Pero <n.pero@mi.flashnet.it>
|
Thu Oct 31 00:46:23 2002 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
|
|
|
@ -2167,6 +2167,7 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
||||||
unsigned char *bBytes = (unsigned char*)[boundary bytes];
|
unsigned char *bBytes = (unsigned char*)[boundary bytes];
|
||||||
unsigned char bInit = bBytes[0];
|
unsigned char bInit = bBytes[0];
|
||||||
BOOL done = NO;
|
BOOL done = NO;
|
||||||
|
BOOL endedFinalPart = NO;
|
||||||
|
|
||||||
[data appendBytes: [d bytes] length: [d length]];
|
[data appendBytes: [d bytes] length: [d length]];
|
||||||
bytes = (unsigned char*)[data mutableBytes];
|
bytes = (unsigned char*)[data mutableBytes];
|
||||||
|
@ -2186,6 +2187,11 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
||||||
|| bytes[lineStart-1] == '\n')
|
|| bytes[lineStart-1] == '\n')
|
||||||
{
|
{
|
||||||
lineEnd = lineStart + bLength;
|
lineEnd = lineStart + bLength;
|
||||||
|
if (lineEnd + 2 < dataEnd && bytes[lineEnd] == '-'
|
||||||
|
&& bytes[lineEnd+1] == '-')
|
||||||
|
{
|
||||||
|
endedFinalPart = YES;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2209,7 +2215,6 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
||||||
{
|
{
|
||||||
NSData *d;
|
NSData *d;
|
||||||
unsigned pos;
|
unsigned pos;
|
||||||
BOOL endedFinalPart = NO;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Found boundary at the end of a section.
|
* Found boundary at the end of a section.
|
||||||
|
@ -2220,7 +2225,6 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
||||||
&& bytes[sectionStart+1] == '-')
|
&& bytes[sectionStart+1] == '-')
|
||||||
{
|
{
|
||||||
sectionStart += 2;
|
sectionStart += 2;
|
||||||
endedFinalPart = YES;
|
|
||||||
}
|
}
|
||||||
if (bytes[sectionStart] == '\r')
|
if (bytes[sectionStart] == '\r')
|
||||||
{
|
{
|
||||||
|
@ -2294,17 +2298,26 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
||||||
bytes = (unsigned char*)[data mutableBytes];
|
bytes = (unsigned char*)[data mutableBytes];
|
||||||
lineStart -= sectionStart;
|
lineStart -= sectionStart;
|
||||||
sectionStart = 0;
|
sectionStart = 0;
|
||||||
|
if (endedFinalPart == YES)
|
||||||
|
{
|
||||||
|
done = YES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Check to see if we have reached content length.
|
* Check to see if we have reached content length or ended multipart
|
||||||
|
* document.
|
||||||
*/
|
*/
|
||||||
if (expect > 0 && rawBodyLength >= expect)
|
if (endedFinalPart == YES || (expect > 0 && rawBodyLength >= expect))
|
||||||
{
|
{
|
||||||
complete = YES;
|
complete = YES;
|
||||||
inBody = NO;
|
inBody = NO;
|
||||||
|
result = NO;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = YES;
|
||||||
}
|
}
|
||||||
result = YES;
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue