Skip to content

Commit

Permalink
added URL escaping for all special characters to fix scrobbling bugs …
Browse files Browse the repository at this point in the history
…for tracks with + (and others) in their names
  • Loading branch information
Matt Patenaude authored and Matt Patenaude committed Mar 16, 2010
1 parent 2283d20 commit 672122b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions LFRequest.m
Expand Up @@ -107,8 +107,13 @@ - (NSString *)queryStringWithParameters:(NSDictionary *)params sign:(BOOL)should
for (NSString *key in params)
{
NSMutableString *escaped = [NSMutableString stringWithString:[[params objectForKey:key] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[escaped replaceOccurrencesOfString:@"%" withString:@"%25" options:NSLiteralSearch range:NSMakeRange(0, [escaped length])];
[escaped replaceOccurrencesOfString:@"&" withString:@"%26" options:NSLiteralSearch range:NSMakeRange(0, [escaped length])];
[escaped replaceOccurrencesOfString:@"=" withString:@"%3D" options:NSLiteralSearch range:NSMakeRange(0, [escaped length])];
[escaped replaceOccurrencesOfString:@"+" withString:@"%2B" options:NSLiteralSearch range:NSMakeRange(0, [escaped length])];
[escaped replaceOccurrencesOfString:@"/" withString:@"%2F" options:NSLiteralSearch range:NSMakeRange(0, [escaped length])];
[escaped replaceOccurrencesOfString:@"?" withString:@"%3F" options:NSLiteralSearch range:NSMakeRange(0, [escaped length])];
[escaped replaceOccurrencesOfString:@"#" withString:@"%23" options:NSLiteralSearch range:NSMakeRange(0, [escaped length])];
[parts addObject:[NSString stringWithFormat:@"%@=%@", key, escaped]];
}

Expand Down

0 comments on commit 672122b

Please sign in to comment.