Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

CFURLCreateStringByAddingPercentEscapesの変更 (issue #95) #126

Merged
merged 6 commits into from Jul 24, 2017
Merged
8 changes: 1 addition & 7 deletions NCMB/NCMBRequest/NCMBRequest.m
Expand Up @@ -78,13 +78,7 @@ +(NSString *)returnSessionToken {
}

+(NSString *)returnEncodedString:(NSString *)originalString {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このメソッドのテストをNCMBTests/NCMBRequestSpec.mに追加してください。

CFStringRef escapedStrRef = CFURLCreateStringByAddingPercentEscapes(
NULL,
(__bridge CFStringRef)originalString,
NULL,
CFSTR(":/?#[]@!$&'()*+,;="),
kCFStringEncodingUTF8 );
NSString *escapedStr = CFBridgingRelease(escapedStrRef);
NSString * escapedStr = [originalString stringByAddingPercentEncodingWithAllowedCharacters:[[NSCharacterSet characterSetWithCharactersInString:@":/?#[]@!$&'()*+,;=\"<>\^`{|}"] invertedSet]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*とescapedStrの間のspaceも削除してください

return escapedStr;
}

Expand Down
15 changes: 2 additions & 13 deletions NCMB/NCMBURLConnection/NCMBURLConnection.m
Expand Up @@ -107,17 +107,6 @@ - (id)initWithPath:(NSString*)path method:(NSString*)method data:(NSData*)data c
return self;
}

- (NSString*)percentEscape:(NSString*)str{
CFStringRef escapedStrRef = CFURLCreateStringByAddingPercentEscapes(
NULL,
(__bridge CFStringRef)str,
NULL,
(__bridge CFStringRef)@"!*();@+,%#\"",
kCFStringEncodingUTF8 );
NSString *escapedStr = CFBridgingRelease(escapedStrRef);
return escapedStr;
}


#pragma mark request

Expand All @@ -141,9 +130,9 @@ - (NSString*)returnEndPoint{
@return NSMutableURLRequest型リクエスト
*/
- (NSMutableURLRequest *)createRequest {
self.query = [self percentEscape:self.query];
self.query = [self.query stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
[self createSignature];
self.path = [self percentEscape:self.path];
self.path = [self.path stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]];

//url生成
NSString *endPointStr = [self returnEndPoint];
Expand Down