Fix opening URLS with special characters in macOS
The Online Tutorials section of InputMap in the editor's built-in
documentation viewer contains this link:
docs.godotengine.org/en/latest/tutorials/inputs/inputevent.html#inputmap
The macOS implementation for opening a link percent-encodes it before
sending it to the browser, resulting in a 404. This is to fix #13422
where filenames with special characters could not be opened in Finder.
However, this breaks URLS so I added a check to see if the resource
scheme is file:// and if so, only then is it escaped. This allows other
schemes like `http`, `ftp`, and `mailto` to be used.
(cherry picked from commit b8e6ff9a7f
)
This commit is contained in:
parent
d4f4e0d7dc
commit
3f5f58b9d8
1 changed files with 7 additions and 2 deletions
|
@ -2320,8 +2320,13 @@ void OS_OSX::make_rendering_thread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Error OS_OSX::shell_open(String p_uri) {
|
Error OS_OSX::shell_open(String p_uri) {
|
||||||
|
NSString *string = [NSString stringWithUTF8String:p_uri.utf8().get_data()];
|
||||||
[[NSWorkspace sharedWorkspace] openURL:[[NSURL alloc] initWithString:[[NSString stringWithUTF8String:p_uri.utf8().get_data()] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]]];
|
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;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue