From 839ca0ea64c2dc10fede3916db244347ee8ba91f Mon Sep 17 00:00:00 2001 From: superzazu Date: Wed, 3 Nov 2021 16:35:24 +0100 Subject: [PATCH] SDL_OpenURL (macOS): try to open path if the url cannot be opened (#4830) * SDL_OpenURL (macOS): try to open path if the url cannot be opened * SDL_OpenURL (macOS): use CFURLCreateWithBytes & LSOpenCFURLRef to correctly escape input * fix type casting + indentation --- src/misc/macosx/SDL_sysurl.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/misc/macosx/SDL_sysurl.m b/src/misc/macosx/SDL_sysurl.m index 5e1070a557..4bd3aa4ddd 100644 --- a/src/misc/macosx/SDL_sysurl.m +++ b/src/misc/macosx/SDL_sysurl.m @@ -27,10 +27,10 @@ int SDL_SYS_OpenURL(const char *url) { @autoreleasepool { - NSString *nsstr = [NSString stringWithUTF8String:url]; - NSURL *nsurl = [NSURL URLWithString:nsstr]; - return [[NSWorkspace sharedWorkspace] openURL:nsurl] ? 0 : -1; + CFURLRef cfurl = CFURLCreateWithBytes(NULL, (const UInt8 *) url, SDL_strlen(url), kCFStringEncodingUTF8, NULL); + OSStatus status = LSOpenCFURLRef(cfurl, NULL); + CFRelease(cfurl); + return status == noErr ? 0 : -1; }} /* vi: set ts=4 sw=4 expandtab: */ -