mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Improve argument checking
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23753 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
977f07e7cd
commit
62d6638993
4 changed files with 44 additions and 22 deletions
|
@ -1,3 +1,10 @@
|
|||
2006-10-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSHTTPURLHandle.m:
|
||||
* Source/NSHTTPCookieStorage.m:
|
||||
* Source/GSHTTPAuthentication.m: Add a little checking for nil/invalid
|
||||
arguments. Make parsing of authentication a little more tolerant.
|
||||
|
||||
2006-10-03 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Version: Bump to version for next release.
|
||||
|
|
|
@ -94,6 +94,11 @@ static GSMimeParser *mimeParser = nil;
|
|||
NSURLProtectionSpace *known = nil;
|
||||
GSHTTPAuthentication *authentication = nil;
|
||||
|
||||
NSAssert([credential isKindOfClass: [NSURLCredential class]] == YES,
|
||||
NSInvalidArgumentException);
|
||||
NSAssert([space isKindOfClass: [NSURLProtectionSpace class]] == YES,
|
||||
NSInvalidArgumentException);
|
||||
|
||||
[storeLock lock];
|
||||
|
||||
/*
|
||||
|
@ -146,18 +151,19 @@ static GSMimeParser *mimeParser = nil;
|
|||
|
||||
space = [self protectionSpaceForURL: URL];
|
||||
sc = [NSScanner scannerWithString: auth];
|
||||
if ([sc scanString: @"Basic" intoString: 0] == YES)
|
||||
key = [mimeParser scanName: sc];
|
||||
if ([key caseInsensitiveCompare: @"Basic"] == NSOrderedSame)
|
||||
{
|
||||
method = NSURLAuthenticationMethodHTTPBasic;
|
||||
domain = [URL path];
|
||||
}
|
||||
else if ([sc scanString: @"Digest" intoString: 0] == YES)
|
||||
else if ([key caseInsensitiveCompare: @"Digest"] == NSOrderedSame)
|
||||
{
|
||||
method = NSURLAuthenticationMethodHTTPDigest;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nil; // Not a known authentication
|
||||
return nil; // Unknown authentication
|
||||
}
|
||||
while ((key = [mimeParser scanName: sc]) != nil)
|
||||
{
|
||||
|
|
|
@ -613,7 +613,6 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
{
|
||||
NSURLProtectionSpace *space;
|
||||
NSString *ac;
|
||||
NSURLCredential *cred;
|
||||
GSHTTPAuthentication *authentication;
|
||||
NSString *method;
|
||||
NSString *a;
|
||||
|
@ -621,25 +620,33 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
ac = [ah value];
|
||||
space = [GSHTTPAuthentication
|
||||
protectionSpaceForAuthentication: ac requestURL: url];
|
||||
if (space != nil)
|
||||
{
|
||||
NSURLCredential *cred;
|
||||
|
||||
/*
|
||||
* Create credential from user and password
|
||||
* stored in the URL.
|
||||
*/
|
||||
cred = [[NSURLCredential alloc]
|
||||
initWithUser: [url user]
|
||||
password: [url password]
|
||||
persistence: NSURLCredentialPersistenceForSession];
|
||||
/*
|
||||
* Create credential from user and password
|
||||
* stored in the URL.
|
||||
*/
|
||||
cred = [[NSURLCredential alloc]
|
||||
initWithUser: [url user]
|
||||
password: [url password]
|
||||
persistence: NSURLCredentialPersistenceForSession];
|
||||
|
||||
/*
|
||||
* Get the digest object and ask it for a header
|
||||
* to use for authorisation.
|
||||
*/
|
||||
authentication = [GSHTTPAuthentication
|
||||
authenticationWithCredential: cred
|
||||
inProtectionSpace: space];
|
||||
/*
|
||||
* Get the digest object and ask it for a header
|
||||
* to use for authorisation.
|
||||
*/
|
||||
authentication = [GSHTTPAuthentication
|
||||
authenticationWithCredential: cred
|
||||
inProtectionSpace: space];
|
||||
|
||||
RELEASE(cred);
|
||||
RELEASE(cred);
|
||||
}
|
||||
else
|
||||
{
|
||||
authentication = nil;
|
||||
}
|
||||
|
||||
method = [request objectForKey: GSHTTPPropertyMethodKey];
|
||||
if (method == nil)
|
||||
|
@ -655,8 +662,8 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
}
|
||||
|
||||
a = [authentication authorizationForAuthentication: ac
|
||||
method: method
|
||||
path: [url path]];
|
||||
method: method
|
||||
path: [url path]];
|
||||
if (a != nil)
|
||||
{
|
||||
[self writeProperty: a forKey: @"Authorization"];
|
||||
|
|
|
@ -111,6 +111,8 @@ static NSHTTPCookieStorage *storage = nil;
|
|||
|
||||
- (void) setCookie: (NSHTTPCookie *)cookie
|
||||
{
|
||||
NSAssert([cookie isKindOfClass: [NSHTTPCookie class]] == YES,
|
||||
NSInvalidArgumentException);
|
||||
[this->_cookies addObject: cookie];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue