nxtbgthng / OAuth2Client

Client library for OAuth2 (currently built against draft 10 of the OAuth2 spec)
855 stars 217 forks source link

Crash when request params values are other than NSString #103

Open pszalko opened 10 years ago

pszalko commented 10 years ago

NSString (NXOAuth2) category crashes when parameter value is other than NSString.

The following code requires every param value to be NSString, but it doesn't check if it's true.

+ (NSString *)nxoauth2_stringWithEncodedQueryParameters:(NSDictionary *)parameters;
{

    NSMutableArray *parameterPairs = [NSMutableArray array];
    for (NSString *key in [parameters allKeys]) {
        NSString *pair = [NSString stringWithFormat:@"%@=%@", [key nxoauth2_URLEncodedString], [[parameters objectForKey:key] nxoauth2_URLEncodedString]];
        [parameterPairs addObject:pair];
    }
    return [parameterPairs componentsJoinedByString:@"&"];
}

Steps to reproduce the issue is to pass anything than NSString to as parameters value.

Example dictionary:

parameters = @{@"key" : @34}