Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Incorrect signature base string when parameters contains reserved characters #10

Merged
merged 1 commit into from Jul 23, 2012

Conversation

Projects
None yet
3 participants
Contributor

sycx commented Jul 20, 2012

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 added a commit that referenced this pull request Jul 23, 2012

@rsieiro rsieiro Merge pull request #10 from sycx/master
Incorrect signature base string when parameters contains reserved characters
f0244d0

@rsieiro rsieiro merged commit f0244d0 into rsieiro:master Jul 23, 2012

Contributor

tuo commented Nov 13, 2012

@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]];
    }];
Owner

rsieiro commented Nov 13, 2012

@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