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 5608b1d411)
This commit is contained in:
Brecht Kuppens 2023-07-02 22:25:17 +02:00 committed by Yuri Sizov
parent 560c52cef2
commit 4944a07044
1 changed files with 2 additions and 7 deletions

View File

@ -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) { 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; bool open_folder = false;
if (DirAccess::dir_exists_absolute(p_path) && p_open_folder) { if (DirAccess::dir_exists_absolute(p_path) && p_open_folder) {
open_folder = true; open_folder = true;
} }
if (p_path.begins_with("\"")) { if (!p_path.is_quoted()) {
p_path = String("\"") + p_path; p_path = p_path.quote();
}
if (p_path.ends_with("\"")) {
p_path = p_path + String("\"");
} }
p_path = p_path.replace("/", "\\"); p_path = p_path.replace("/", "\\");