Skip to content

Commit

Permalink
fine tuning what gets escaped. This is harder than it should be
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinrue committed Feb 15, 2015
1 parent 3fd83ab commit 1d71ee7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Source/DefaultBrowserAction.m
Expand Up @@ -149,9 +149,17 @@ - (void)handleURL:(NSString *)url {
if (!browser) {
browser = @"com.apple.Safari";
}
NSString *decoded = [url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSString *decodedURL = [url stringByRemovingPercentEncoding];
NSString *newURL = (NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL,
(CFStringRef)decodedURL,
(CFStringRef)@"#",
(CFStringRef)@" ",
kCFStringEncodingUTF8 );
NSArray *urls = [NSArray arrayWithObject:[NSURL URLWithString:newURL]];
[newURL release];

NSArray *urls = [NSArray arrayWithObject:[NSURL URLWithString:[decoded stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];

[[NSWorkspace sharedWorkspace] openURLs:urls withAppBundleIdentifier:browser options:NSWorkspaceLaunchDefault additionalEventParamDescriptor:nil launchIdentifiers:nil];
}
Expand Down

0 comments on commit 1d71ee7

Please sign in to comment.