mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Fix error in handling header unfolding
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16727 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
eedf8ca265
commit
eae4993fed
2 changed files with 62 additions and 50 deletions
|
@ -2419,10 +2419,21 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
||||||
/*
|
/*
|
||||||
* Eat a newline that is part of a cr-lf sequence.
|
* Eat a newline that is part of a cr-lf sequence.
|
||||||
*/
|
*/
|
||||||
input++;
|
if (input < dataEnd)
|
||||||
if (c == '\r' && input < dataEnd && bytes[input] == '\n')
|
{
|
||||||
{
|
/*
|
||||||
|
* If we had an end-of-line with nothing else, we must have
|
||||||
|
* finished unwrapping at the final boundary.
|
||||||
|
*/
|
||||||
|
if (input == lineStart)
|
||||||
|
{
|
||||||
|
unwrappingComplete = YES;
|
||||||
|
}
|
||||||
input++;
|
input++;
|
||||||
|
if (c == '\r' && input < dataEnd && bytes[input] == '\n')
|
||||||
|
{
|
||||||
|
input++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2432,6 +2443,10 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
|
||||||
&& ((c = bytes[input]) == '\r' || c == '\n' || isspace(c) == 0))
|
&& ((c = bytes[input]) == '\r' || c == '\n' || isspace(c) == 0))
|
||||||
{
|
{
|
||||||
unwrappingComplete = YES;
|
unwrappingComplete = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unwrappingComplete == YES)
|
||||||
|
{
|
||||||
bytes[lineEnd] = '\0';
|
bytes[lineEnd] = '\0';
|
||||||
/*
|
/*
|
||||||
* If this is a zero-length line, we have reached the end of
|
* If this is a zero-length line, we have reached the end of
|
||||||
|
|
|
@ -301,58 +301,55 @@ static void debugWrite(NSData *data)
|
||||||
d = [dict objectForKey: NSFileHandleNotificationDataItem];
|
d = [dict objectForKey: NSFileHandleNotificationDataItem];
|
||||||
if (debug == YES) debugRead(d);
|
if (debug == YES) debugRead(d);
|
||||||
|
|
||||||
if ([parser parse: d] == NO || [parser isComplete] == YES)
|
if ([parser parse: d] == NO)
|
||||||
{
|
{
|
||||||
if ([parser isComplete] == YES)
|
if (debug == YES)
|
||||||
{
|
{
|
||||||
GSMimeHeader *info;
|
NSLog(@"HTTP parse failure - %@", parser);
|
||||||
NSString *val;
|
|
||||||
|
|
||||||
connectionState = idle;
|
|
||||||
[nc removeObserver: self
|
|
||||||
name: NSFileHandleReadCompletionNotification
|
|
||||||
object: sock];
|
|
||||||
[sock closeFile];
|
|
||||||
DESTROY(sock);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Retrieve essential keys from document
|
|
||||||
*/
|
|
||||||
info = [document headerNamed: @"http"];
|
|
||||||
val = [info objectForKey: NSHTTPPropertyServerHTTPVersionKey];
|
|
||||||
if (val != nil)
|
|
||||||
{
|
|
||||||
[pageInfo setObject: val
|
|
||||||
forKey: NSHTTPPropertyServerHTTPVersionKey];
|
|
||||||
}
|
|
||||||
val = [info objectForKey: NSHTTPPropertyStatusCodeKey];
|
|
||||||
if (val != nil)
|
|
||||||
{
|
|
||||||
[pageInfo setObject: val forKey: NSHTTPPropertyStatusCodeKey];
|
|
||||||
}
|
|
||||||
val = [info objectForKey: NSHTTPPropertyStatusReasonKey];
|
|
||||||
if (val != nil)
|
|
||||||
{
|
|
||||||
[pageInfo setObject: val forKey: NSHTTPPropertyStatusReasonKey];
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Tell superclass that we have successfully loaded the data.
|
|
||||||
*/
|
|
||||||
d = [parser data];
|
|
||||||
r = NSMakeRange(bodyPos, [d length] - bodyPos);
|
|
||||||
bodyPos = 0;
|
|
||||||
[self didLoadBytes: [d subdataWithRange: r]
|
|
||||||
loadComplete: YES];
|
|
||||||
}
|
}
|
||||||
else
|
[self endLoadInBackground];
|
||||||
|
[self backgroundLoadDidFailWithReason: @"Response parse failed"];
|
||||||
|
}
|
||||||
|
else if ([parser isComplete] == YES)
|
||||||
|
{
|
||||||
|
GSMimeHeader *info;
|
||||||
|
NSString *val;
|
||||||
|
|
||||||
|
connectionState = idle;
|
||||||
|
[nc removeObserver: self
|
||||||
|
name: NSFileHandleReadCompletionNotification
|
||||||
|
object: sock];
|
||||||
|
[sock closeFile];
|
||||||
|
DESTROY(sock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve essential keys from document
|
||||||
|
*/
|
||||||
|
info = [document headerNamed: @"http"];
|
||||||
|
val = [info objectForKey: NSHTTPPropertyServerHTTPVersionKey];
|
||||||
|
if (val != nil)
|
||||||
{
|
{
|
||||||
if (debug == YES)
|
[pageInfo setObject: val
|
||||||
{
|
forKey: NSHTTPPropertyServerHTTPVersionKey];
|
||||||
NSLog(@"HTTP parse failure - %@", parser);
|
|
||||||
}
|
|
||||||
[self endLoadInBackground];
|
|
||||||
[self backgroundLoadDidFailWithReason: @"Response parse failed"];
|
|
||||||
}
|
}
|
||||||
|
val = [info objectForKey: NSHTTPPropertyStatusCodeKey];
|
||||||
|
if (val != nil)
|
||||||
|
{
|
||||||
|
[pageInfo setObject: val forKey: NSHTTPPropertyStatusCodeKey];
|
||||||
|
}
|
||||||
|
val = [info objectForKey: NSHTTPPropertyStatusReasonKey];
|
||||||
|
if (val != nil)
|
||||||
|
{
|
||||||
|
[pageInfo setObject: val forKey: NSHTTPPropertyStatusReasonKey];
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Tell superclass that we have successfully loaded the data.
|
||||||
|
*/
|
||||||
|
d = [parser data];
|
||||||
|
r = NSMakeRange(bodyPos, [d length] - bodyPos);
|
||||||
|
bodyPos = 0;
|
||||||
|
[self didLoadBytes: [d subdataWithRange: r]
|
||||||
|
loadComplete: YES];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue