Permalink
Browse files

Uses a mutable string object for escaping URLs.

  • Loading branch information...
1 parent 54c87a4 commit de7edbb5e952359d59623043648b278f623be208 @zonble committed Sep 29, 2010
@@ -203,25 +203,23 @@ - (NSString *)GETStringFromDictionary:(NSDictionary *)inDictionary
if ([key isEqual:[[d allKeys] objectAtIndex:0]]) {
[s setString:@"?"];
}
- NSString *v = [d valueForKey:key];
- v = [v stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- v = [v stringByReplacingOccurrencesOfString:@"&" withString:@"%26"];
- v = [v stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"];
- v = [v stringByReplacingOccurrencesOfString:@"," withString:@"%2C"];
- v = [v stringByReplacingOccurrencesOfString:@"/" withString:@"%2F"];
- v = [v stringByReplacingOccurrencesOfString:@":" withString:@"%3A"];
- v = [v stringByReplacingOccurrencesOfString:@";" withString:@"%3B"];
- v = [v stringByReplacingOccurrencesOfString:@"=" withString:@"%3D"];
- v = [v stringByReplacingOccurrencesOfString:@"?" withString:@"%3F"];
- v = [v stringByReplacingOccurrencesOfString:@"@" withString:@"%40"];
- v = [v stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
- v = [v stringByReplacingOccurrencesOfString:@"\t" withString:@"%09"];
- v = [v stringByReplacingOccurrencesOfString:@"#" withString:@"%23"];
- v = [v stringByReplacingOccurrencesOfString:@"<" withString:@"%3C"];
- v = [v stringByReplacingOccurrencesOfString:@">" withString:@"%3E"];
- v = [v stringByReplacingOccurrencesOfString:@"\"" withString:@"%22"];
- v = [v stringByReplacingOccurrencesOfString:@"\n" withString:@"%0A"];
-
+ NSMutableString *v = [NSMutableString stringWithString:[[d valueForKey:key] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+ [v replaceOccurrencesOfString:@"&" withString:@"%26" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@"+" withString:@"%2B" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@"," withString:@"%2C" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@"/" withString:@"%2F" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@":" withString:@"%3A" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@";" withString:@"%3B" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@"=" withString:@"%3D" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@"?" withString:@"%3F" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@"@" withString:@"%40" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@" " withString:@"%20" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@"\t" withString:@"%09" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@"#" withString:@"%23" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@"<" withString:@"%3C" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@">" withString:@"%3E" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@"\"" withString:@"%22" options:0 range:NSMakeRange(0, [v length])];
+ [v replaceOccurrencesOfString:@"\n" withString:@"%0A"options:0 range:NSMakeRange(0, [v length])];
[s appendFormat:@"%@=%@", key, v];
if (![key isEqual:[[d allKeys] lastObject]]) {
[s appendString:@"&"];
@@ -297,7 +297,14 @@
isa = PBXProject;
buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "ObjectivePlurk" */;
compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
hasScannedForEncodings = 1;
+ knownRegions = (
+ English,
+ Japanese,
+ French,
+ German,
+ );
mainGroup = 0867D691FE84028FC02AAC07 /* ObjectivePlurk */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";

0 comments on commit de7edbb

Please sign in to comment.