diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index f330ec43a8f..ab31e99e113 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -2320,8 +2320,13 @@ void OS_OSX::make_rendering_thread() { } 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; }