From c5ecf80bba2dd1f28ab612b75c6d52504e6dc469 Mon Sep 17 00:00:00 2001 From: Rory Fewell Date: Thu, 4 Apr 2024 20:34:36 +0100 Subject: [PATCH] Enhancement: Fixes #274, exec - file:// URI scheme needs special handling --- shared/exec/src/exec.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/shared/exec/src/exec.c b/shared/exec/src/exec.c index 711c92f..83dfe3b 100644 --- a/shared/exec/src/exec.c +++ b/shared/exec/src/exec.c @@ -403,19 +403,41 @@ static gboolean parse_url_in_cmdline( return FALSE; } - // Command line IS a URL, retrieve the scheme, query the handling program... + // Command line IS a URL, retrieve the scheme // WINTC_LOG_USER_DEBUG("Yeah, looks like a URL."); uri_scheme = g_match_info_fetch(match_info, 1); - mime_type = g_strdup_printf( - "x-scheme-handler/%s", - uri_scheme - ); + + g_match_info_free(match_info); + + // Special case: if the scheme is file:// then convert to just the file + // path + // + if (g_ascii_strcasecmp(uri_scheme, "file") == 0) + { + WINTC_SAFE_REF_SET( + out_cmdline, + g_uri_unescape_string( + cmdline + strlen("file://"), + NULL + ) + ); + + g_free(uri_scheme); + + return FALSE; + } + + // Continue with normal handling - look up a handler for the scheme + // + mime_type = g_strdup_printf( + "x-scheme-handler/%s", + uri_scheme + ); handler_entry = wintc_query_mime_handler(mime_type, &error); - g_match_info_free(match_info); g_free(mime_type); g_free(uri_scheme);