Merge pull request #40111 from DanielZTing/master
Fix opening URLS with special characters in macOS
This commit is contained in:
commit
c2a0bfa95b
1 changed files with 7 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue