diff --git a/ChangeLog b/ChangeLog index 1abf0f530..5ab27b0a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-04-26 Richard Frith-Macdonald + + * Source/GSFTPURLHandle.m: Implement full support for multiline + responses. Fix for bug #26348 + 2009-04-26 Richard Frith-Macdonald * Headers/Foundation/NSTimeZone.h: diff --git a/Source/GSFTPURLHandle.m b/Source/GSFTPURLHandle.m index 514526f2f..8c165acae 100644 --- a/Source/GSFTPURLHandle.m +++ b/Source/GSFTPURLHandle.m @@ -485,6 +485,7 @@ NSString * const GSTelnetTextKey = @"GSTelnetTextKey"; NSFileHandle *dHandle; NSURL *url; NSData *wData; + NSString *term; enum { idle, cConnect, // Establishing control connection @@ -553,6 +554,7 @@ static NSLock *urlLock = nil; } RELEASE(url); RELEASE(wData); + RELEASE(term); [super dealloc]; } @@ -598,14 +600,46 @@ static NSLock *urlLock = nil; text = [info objectForKey: GSTelnetTextKey]; // NSLog(@"Ctl: %@", text); - /* - * Find first reply line which is not a continuation of another. + /* Find first reply line which is not a continuation of another. */ enumerator = [text objectEnumerator]; while ((line = [enumerator nextObject]) != nil) { - if ([line length] > 4 && [line characterAtIndex: 3] != '-') + if (term == nil) { + if ([line length] > 4) + { + char buf[4]; + + buf[0] = (char)[line characterAtIndex: 0]; + buf[1] = (char)[line characterAtIndex: 1]; + buf[2] = (char)[line characterAtIndex: 2]; + buf[3] = (char)[line characterAtIndex: 3]; + if (isdigit(buf[0]) && isdigit(buf[1]) && isdigit(buf[2])) + { + if (buf[3] == '-') + { + /* Got start of a multiline block ... + * set the terminator we need to look for. + */ + buf[3] = ' '; + term = [[NSString alloc] + initWithCString: buf length: 4]; + } + else if (buf[3] == ' ') + { + /* Found single line response. + */ + break; + } + } + } + } + else if ([line hasPrefix: term] == YES) + { + /* Found end of a multiline response. + */ + DESTROY(term); break; } }