Skip to content

Fix mvim:// not handling paths with spaces #1002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/MacVim/MMAppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1744,19 +1744,32 @@ - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event
NSEnumerator *enumerator = [queries objectEnumerator];
NSString *param;
while ((param = [enumerator nextObject])) {
// query: <field>=<value>
NSArray *arr = [param componentsSeparatedByString:@"="];
if ([arr count] == 2) {
// parse field
NSString *f = [arr objectAtIndex:0];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
[dict setValue:[[arr lastObject] stringByRemovingPercentEncoding]
forKey:[[arr objectAtIndex:0] stringByRemovingPercentEncoding]];
f = [f stringByRemovingPercentEncoding];
#else
[dict setValue:[[arr lastObject]
stringByReplacingPercentEscapesUsingEncoding:
NSUTF8StringEncoding]
forKey:[[arr objectAtIndex:0]
stringByReplacingPercentEscapesUsingEncoding:
NSUTF8StringEncoding]];
f = [f stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
#endif

// parse value
NSString *v = [arr objectAtIndex:1];

// do not decode url, since it's a file URI
BOOL decode = ![f isEqualToString:@"url"];
if (decode)
{
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11
v = [f stringByRemovingPercentEncoding];
#else
v = [f stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
#endif
}

[dict setValue:v forKey:f];
}
}

Expand Down