Why returns CFURLCreateWithString no valid url (=NULL)?


#1

I wonder, what the cause could be that CFURLCreateWithString returns NULL. Has anybody experienced this behaviour?

Below code add additional checks.

bool juce_launchFile (const String& fileName, 
                      const String& parameters)
{
    if (fileName.startsWithIgnoreCase (T("http:")))
    {
		bool ok = false;
        CFStringRef urlString = PlatformUtilities::juceStringToCFString (fileName);
		if(urlString)
		{
			CFURLRef url = CFURLCreateWithString (kCFAllocatorDefault, urlString, 0);
			CFRelease (urlString);
			if(url)
			{
				ok = (LSOpenCFURLRef (url, 0) == noErr);
				CFRelease (url);
			}
		}
        return ok;
    }
...

#2

Good point. I’ll throw those extra checks in, just in case.


#3

I seem to recall that if the URL isn’t “well formed” (based on such and such standards and definitions – see the apple dev docs) then the CFURL functions can be unpredictable.


#4

Found it :oops:


#5