File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,7 +89,14 @@ + (NSURL *)NSURL:(id)json
8989
9090 // Check if it has a scheme
9191 if ([path rangeOfString: @" :" ].location != NSNotFound ) {
92- path = [path stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
92+ NSMutableCharacterSet *urlAllowedCharacterSet = [NSMutableCharacterSet new ];
93+ [urlAllowedCharacterSet formUnionWithCharacterSet: [NSCharacterSet URLUserAllowedCharacterSet ]];
94+ [urlAllowedCharacterSet formUnionWithCharacterSet: [NSCharacterSet URLPasswordAllowedCharacterSet ]];
95+ [urlAllowedCharacterSet formUnionWithCharacterSet: [NSCharacterSet URLHostAllowedCharacterSet ]];
96+ [urlAllowedCharacterSet formUnionWithCharacterSet: [NSCharacterSet URLPathAllowedCharacterSet ]];
97+ [urlAllowedCharacterSet formUnionWithCharacterSet: [NSCharacterSet URLQueryAllowedCharacterSet ]];
98+ [urlAllowedCharacterSet formUnionWithCharacterSet: [NSCharacterSet URLFragmentAllowedCharacterSet ]];
99+ path = [path stringByAddingPercentEncodingWithAllowedCharacters: urlAllowedCharacterSet];
93100 URL = [NSURL URLWithString: path];
94101 if (URL) {
95102 return URL;
Original file line number Diff line number Diff line change 3333static NSURL *getInspectorDeviceUrl (NSURL *bundleURL)
3434{
3535 NSNumber *inspectorProxyPort = @8082 ;
36- NSString *escapedDeviceName = [[[UIDevice currentDevice ] name ] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding ];
37- NSString *escapedAppName = [[[NSBundle mainBundle ] bundleIdentifier ] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding ];
36+ NSString *escapedDeviceName = [[[UIDevice currentDevice ] name ] stringByAddingPercentEncodingWithAllowedCharacters: NSCharacterSet .URLQueryAllowedCharacterSet ];
37+ NSString *escapedAppName = [[[NSBundle mainBundle ] bundleIdentifier ] stringByAddingPercentEncodingWithAllowedCharacters: NSCharacterSet .URLQueryAllowedCharacterSet ];
3838 return [NSURL URLWithString: [NSString stringWithFormat: @" http://%@ /inspector/device?name=%@ &app=%@ " ,
3939 getServerHost (bundleURL, inspectorProxyPort),
4040 escapedDeviceName,
4444static NSURL *getAttachDeviceUrl (NSURL *bundleURL, NSString *title)
4545{
4646 NSNumber *metroBundlerPort = @8081 ;
47- NSString *escapedDeviceName = [[[UIDevice currentDevice ] name ] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding ];
48- NSString *escapedAppName = [[[NSBundle mainBundle ] bundleIdentifier ] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding ];
47+ NSString *escapedDeviceName = [[[UIDevice currentDevice ] name ] stringByAddingPercentEncodingWithAllowedCharacters: NSCharacterSet .URLHostAllowedCharacterSet ];
48+ NSString *escapedAppName = [[[NSBundle mainBundle ] bundleIdentifier ] stringByAddingPercentEncodingWithAllowedCharacters: NSCharacterSet .URLHostAllowedCharacterSet ];
4949 return [NSURL URLWithString: [NSString stringWithFormat: @" http://%@ /attach-debugger-nuclide?title=%@ &device=%@ &app=%@ " ,
5050 getServerHost (bundleURL, metroBundlerPort),
5151 title,
Original file line number Diff line number Diff line change @@ -247,7 +247,7 @@ - (BOOL)webView:(__unused UIWebView *)webView shouldStartLoadWithRequest:(NSURLR
247247 if (isJSNavigation && [request.URL.host isEqualToString: kPostMessageHost ]) {
248248 NSString *data = request.URL .query ;
249249 data = [data stringByReplacingOccurrencesOfString: @" +" withString: @" " ];
250- data = [data stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding ];
250+ data = [data stringByAddingPercentEncodingWithAllowedCharacters: NSCharacterSet .URLQueryAllowedCharacterSet ];
251251
252252 NSMutableDictionary <NSString *, id > *event = [self baseEvent ];
253253 [event addEntriesFromDictionary: @{
You can’t perform that action at this time.
0 commit comments