Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Incorrect signature base string when parameters contains reserved characters #10

Merged
merged 1 commit into from

3 participants

@sycx

All parameters has been Pre-encoded by MKNetworkKit.
Need to be decoded before using.

@sycx sycx Fix: Incorrect signature base string when parameters contains reserve…
…d characters

All parameters has been Pre-encoded by MKNetworkKit.
Need to be decoded before using.
76f0f4b
@rsieiro rsieiro merged commit f0244d0 into from
@tuo

@sycx has a problem.
If query parameter contains ampersand (i.e. tv&movie) , then based on @sycx 's solution, it would try decode it first and separate by ampersand, which would cause very strange problem.

As all parameters are encoded from MKNetworkKit, what you can do is just use encode one like following commit:

fee1496

// Only include GET and POST fields if there are no files or data to be posted
if ([request.filesToBePosted count] == 0 && [request.dataToBePosted count] == 0) {
    // Add parameters from the query string
    NSArray *pairs = [url.query componentsSeparatedByString:@"&"];
    [pairs enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        NSArray *elements = [obj componentsSeparatedByString:@"="];
        NSString *key = [elements objectAtIndex:0];
        NSString *value = (elements.count > 1) ? [elements objectAtIndex:1] : @"";

        [parameters addObject:[NSDictionary dictionaryWithObjectsAndKeys:key, @"key", value, @"value", nil]];
    }];
@rsieiro
Owner

@tuo you're right. Could you please issue a pull request with that commit, so I can merge it in the code?

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 20, 2012
  1. @sycx

    Fix: Incorrect signature base string when parameters contains reserve…

    sycx authored
    …d characters
    
    All parameters has been Pre-encoded by MKNetworkKit.
    Need to be decoded before using.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  RSOAuthEngine/RSOAuthEngine.m
View
2  RSOAuthEngine/RSOAuthEngine.m
@@ -147,7 +147,7 @@ - (NSString *)signatureBaseStringForRequest:(MKNetworkOperation *)request signOn
// Add parameters from the query string
if (!onlyOAuth) {
NSURL *url = [NSURL URLWithString:request.url];
- NSArray *pairs = [url.query componentsSeparatedByString:@"&"];
+ NSArray *pairs = [[url.query urlDecodedString] componentsSeparatedByString:@"&"];
[pairs enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
NSArray *elements = [obj componentsSeparatedByString:@"="];
NSString *key = [[elements objectAtIndex:0] urlEncodedString];
Something went wrong with that request. Please try again.