Fix NSURL misdetection routing SSH commands to openURL - #302
Conversation
Only treat command strings as URLs when they have an explicit http/https scheme, since NSURL's parser has become more lenient over time and was misrouting SSH commands to NSWorkspace openURL. Also logs AppleScript execution errors instead of discarding them. Bumps minimum deployment target from 10.9 to 10.13.
|
Hit the same bug independently and landed on a slightly different rule, sharing in case it's useful. Restricting to An alternative that keeps them working: treat an entry as a URL only when it has a scheme and contains no whitespace. - (NSURL *) urlForEntry: (NSString *) entry
{
if ([entry rangeOfCharacterFromSet:[NSCharacterSet whitespaceCharacterSet]].location != NSNotFound)
return nil;
NSURL *url = [NSURL URLWithString:entry];
return url.scheme.length ? url : nil;
}The whitespace test is what does the work. Every realistic command contains a space, and the ones that legitimately contain a colon ( Root cause, for anyone who finds this by searching the error message: Separately, +1 on logging the AppleScript execution errors. That's a real improvement I didn't have. I have a fork at https://github.com/morri5/shuttle carrying this plus a universal arm64 build and a |
Only treat command strings as URLs when they have an explicit http/https scheme, since NSURL's parser has become more lenient over time and was misrouting SSH commands to NSWorkspace openURL. Also logs AppleScript execution errors instead of discarding them. Bumps minimum deployment target from 10.9 to 10.13.