From 4944a07044b17d5e18b3a52aa5327bb5e489122f Mon Sep 17 00:00:00 2001 From: Brecht Kuppens Date: Sun, 2 Jul 2023 22:25:17 +0200 Subject: [PATCH] Windows: Always double-quote path when launching explorer.exe to browse Code now always double quotes the filename to use as command line argument when calling explorer.exe. In particular, commas in a filename would be interpreted by explorer.exe as separators for commands. Similarly a trim_suffix for "file://" is assumed to be a mistake, this could potentially be a PREfix that we want to strip, but never a suffix. Since it didn't seem needed in the end, we removed it. (cherry picked from commit 5608b1d4117c4d7931905f8109d39cba6fa2128f) --- platform/windows/os_windows.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index df93631ef05..12f4c18a8b8 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1356,18 +1356,13 @@ Error OS_Windows::shell_open(String p_uri) { } Error OS_Windows::shell_show_in_file_manager(String p_path, bool p_open_folder) { - p_path = p_path.trim_suffix("file://"); - bool open_folder = false; if (DirAccess::dir_exists_absolute(p_path) && p_open_folder) { open_folder = true; } - if (p_path.begins_with("\"")) { - p_path = String("\"") + p_path; - } - if (p_path.ends_with("\"")) { - p_path = p_path + String("\""); + if (!p_path.is_quoted()) { + p_path = p_path.quote(); } p_path = p_path.replace("/", "\\");