diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-15 14:33:03 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-15 19:03:41 +0200 |
commit | 675e6dd88085dae6cfd67562fb164542e784e31c (patch) | |
tree | a9153c7835461cf6a0d288e47878dc100da1bad1 /src | |
parent | fe31a612df712ee8ef55c1923318a842c7426dbb (diff) |
macOS: Decoding handled URLs
When an URL is provided via the system URL handling mechanism, decode any percent-encoded characters in it.
Diffstat (limited to 'src')
-rw-r--r-- | src/macos.m | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/macos.m b/src/macos.m index 9d46d84b..c6c30fa5 100644 --- a/src/macos.m +++ b/src/macos.m | |||
@@ -330,7 +330,10 @@ void enableMomentumScroll_MacOS(void) { | |||
330 | - (void)handleURLEvent:(NSAppleEventDescriptor*)event | 330 | - (void)handleURLEvent:(NSAppleEventDescriptor*)event |
331 | withReplyEvent:(NSAppleEventDescriptor*)replyEvent { | 331 | withReplyEvent:(NSAppleEventDescriptor*)replyEvent { |
332 | NSString *url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; | 332 | NSString *url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; |
333 | postCommandf_App("~open url:%s", [url cStringUsingEncoding:NSUTF8StringEncoding]); | 333 | iString *str = newCStr_String([url cStringUsingEncoding:NSUTF8StringEncoding]); |
334 | str = urlDecodeExclude_String(collect_String(str), "/#?:"); | ||
335 | postCommandf_App("~open url:%s", cstr_String(str)); | ||
336 | delete_String(str); | ||
334 | } | 337 | } |
335 | @end | 338 | @end |
336 | 339 | ||
@@ -512,7 +515,7 @@ void handleCommand_MacOS(const char *cmd) { | |||
512 | NSMenu *menu = mainMenuItem.submenu; | 515 | NSMenu *menu = mainMenuItem.submenu; |
513 | if (menu) { | 516 | if (menu) { |
514 | int itemIndex = 0; | 517 | int itemIndex = 0; |
515 | for (NSMenuItem *menuItem in menu.itemArray) { | 518 | for (NSMenuItem *menuItem in menu.itemArray) { |
516 | NSString *command = [myDel commandForItem:menuItem]; | 519 | NSString *command = [myDel commandForItem:menuItem]; |
517 | if (!command && mainIndex == 6 && itemIndex == 0) { | 520 | if (!command && mainIndex == 6 && itemIndex == 0) { |
518 | /* Window > Close */ | 521 | /* Window > Close */ |