launchInDefaultBrowser() fails if URL length > 1024

Hi,
The URL::launchInDefaultBrowser() method does not work on Mac if the URL string length is longer than 1024.

I found that the juceStringToNS instruction in the Process::openDocument method (juce_mac_Files.mm) never returns in that case.

    bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String& parameters)
    {
        JUCE_AUTORELEASEPOOL
        {
            NSURL* filenameAsURL = [NSURL URLWithString: juceStringToNS (fileName)];

      #if JUCE_IOS
        (void) parameters;
        return [[UIApplication sharedApplication] openURL: filenameAsURL];
      #else
        NSWorkspace* workspace = [NSWorkspace sharedWorkspace];

        if (parameters.isEmpty())
            return [workspace openFile: juceStringToNS (fileName)]
                || [workspace openURL: filenameAsURL];

        ...

As a result, I modified it like this to make it work:

      if (parameters.isEmpty())
        {
            int iLength =fileName.length();
            if(iLength <= 1024)   // if length > 1024, juceStringToNS doesn't return
            {
                return [workspace openFile: juceStringToNS (fileName)]
                || [workspace openURL: filenameAsURL];
            }
            else
            {
                return [workspace openURL: filenameAsURL];
            }

        }

I don’t understand where you’re getting the 1024 limit from… I can’t see that anywhere in the code??

Actually, after several tests, i found out that when the url length was longer than this limit, the browser was not launched. So I wrote down this little test, to make my code work, and notified it to you! But I guess you guys will write a ‘prettier’ code!
May be 1024 is the limit of a Mac file path?

So you mean that with longer paths, the call to [workspace openFile:] would return true but actually fail…? Very odd, that almost sounds like an OSX bug.

But thanks for the heads-up, I guess there’s no harm in adding some logic along these lines. It probably is due to a filesystem length limitation.

Yes that’s it.
Yes, I also thought about an OSX bug.
For your information, I was on OSX 10.10.

#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ #define PATH_MAX 1024 /* max bytes in pathname */
Yes it is

Rail