Skip to content

Commit

Permalink
this is encoding the whole url, so use all allowed url parts
Browse files Browse the repository at this point in the history
  • Loading branch information
pvinis committed Jan 25, 2019
1 parent 1183e32 commit 5cab758
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,14 @@ + (NSURL *)NSURL:(id)json

// Check if it has a scheme
if ([path rangeOfString:@":"].location != NSNotFound) {
path = [path stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
NSMutableCharacterSet *urlAllowedCharacterSet = [NSMutableCharacterSet new];
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLUserAllowedCharacterSet]];
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLPasswordAllowedCharacterSet]];
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLHostAllowedCharacterSet]];
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLPathAllowedCharacterSet]];
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLQueryAllowedCharacterSet]];
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLFragmentAllowedCharacterSet]];
path = [path stringByAddingPercentEncodingWithAllowedCharacters:urlAllowedCharacterSet];
URL = [NSURL URLWithString:path];
if (URL) {
return URL;
Expand Down

0 comments on commit 5cab758

Please sign in to comment.