diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-07-05 00:51:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-05 00:51:13 +0200 |
commit | c2a0bfa95beb618d500e8346929bc9edb825e1c7 (patch) | |
tree | 9f0a5c6d45106aeec59360c6a548deffbf2bae22 | |
parent | 597b268150b208f3d3edf4410b5f6741e1d153f4 (diff) | |
parent | b8e6ff9a7fb2eb98e92344d567a1ef085dfb78a4 (diff) |
Merge pull request #40111 from DanielZTing/master
Fix opening URLS with special characters in macOS
-rw-r--r-- | platform/osx/os_osx.mm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index dba96ccfcd..4ca89ff4b2 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -272,7 +272,13 @@ String OS_OSX::get_system_dir(SystemDir p_dir) const { } Error OS_OSX::shell_open(String p_uri) { - [[NSWorkspace sharedWorkspace] openURL:[[NSURL alloc] initWithString:[[NSString stringWithUTF8String:p_uri.utf8().get_data()] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]]]; + NSString *string = [NSString stringWithUTF8String:p_uri.utf8().get_data()]; + NSURL *uri = [[NSURL alloc] initWithString:string]; + // Escape special characters in filenames + if (!uri || !uri.scheme || [uri.scheme isEqual:@"file"]) { + uri = [[NSURL alloc] initWithString:[string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]]; + } + [[NSWorkspace sharedWorkspace] openURL:uri]; return OK; } |