mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 08:26:27 +00:00
don't waity for a CRLF at the end of the final boundary in a multipart document
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35879 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1c2ce264aa
commit
2171c6971d
2 changed files with 42 additions and 26 deletions
|
@ -1,3 +1,10 @@
|
|||
2012-12-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSMime.m: Fix parsing of final boundary in a multipart
|
||||
document so that the trailing '--' ends the boundary and no CRLF
|
||||
is required. The grammar in RFC1341 says that the final boundary
|
||||
does not need a CRLF terminator.
|
||||
|
||||
2012-12-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSTLS.m:
|
||||
|
|
|
@ -2601,41 +2601,50 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
|||
if (lineStart == 0 || buf[lineStart-1] == '\r'
|
||||
|| buf[lineStart-1] == '\n')
|
||||
{
|
||||
BOOL lastPart = NO;
|
||||
|
||||
lineEnd = lineStart + bLength;
|
||||
eol = lineEnd;
|
||||
if (lineEnd + 2 <= len && buf[lineEnd] == '-'
|
||||
&& buf[lineEnd+1] == '-')
|
||||
{
|
||||
/* The final boundary (shown by the trailng '--').
|
||||
* Any data after this should be ignored.
|
||||
* NB. careful reading of section 7.2.1 of RFC1341
|
||||
* reveals that the final boundary does NOT include
|
||||
* a trailing CRLF (but that excess data after the
|
||||
* final boundary is to be ignored).
|
||||
*/
|
||||
eol += 2;
|
||||
lastPart = YES;
|
||||
}
|
||||
/*
|
||||
* Ignore space/tab characters after boundary marker
|
||||
* and before crlf. Strictly this is wrong ... but
|
||||
* at least one mailer generates bogus whitespace here.
|
||||
*/
|
||||
while (eol < len
|
||||
&& (buf[eol] == ' ' || buf[eol] == '\t'))
|
||||
{
|
||||
eol++;
|
||||
}
|
||||
if (eol < len && buf[eol] == '\r')
|
||||
{
|
||||
eol++;
|
||||
}
|
||||
if (eol < len && buf[eol] == '\n')
|
||||
{
|
||||
eol++;
|
||||
flags.wantEndOfLine = 0;
|
||||
endedFinalPart = YES;
|
||||
found = YES;
|
||||
endedFinalPart = lastPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags.wantEndOfLine = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Ignore space/tab characters after boundary marker
|
||||
* and before crlf. Strictly this is wrong ... but
|
||||
* at least one mailer generates bogus whitespace.
|
||||
*/
|
||||
while (eol < len
|
||||
&& (buf[eol] == ' ' || buf[eol] == '\t'))
|
||||
{
|
||||
eol++;
|
||||
}
|
||||
if (eol < len && buf[eol] == '\r')
|
||||
{
|
||||
eol++;
|
||||
}
|
||||
if (eol < len && buf[eol] == '\n')
|
||||
{
|
||||
eol++;
|
||||
flags.wantEndOfLine = 0;
|
||||
found = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags.wantEndOfLine = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue