From 6b4fe7975f0dbd32d45fbb7a6708fc39fbd92996 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 21 May 2018 22:10:38 +0200 Subject: [PATCH] Fix of the previous commit: When asking the operating system to open the datadir using the platform specific file explorer, enquote and escape the path. --- xs/src/slic3r/GUI/GUI.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 99b63e1f98..afb0cf6141 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -5,8 +5,7 @@ #include #include -#include -#include +#include #include #if __APPLE__ @@ -931,6 +930,7 @@ void about() void desktop_open_datadir_folder() { + // Execute command to open a file explorer, platform dependent. std::string cmd = #ifdef _WIN32 "explorer " @@ -940,7 +940,21 @@ void desktop_open_datadir_folder() "xdg-open " #endif ; - cmd += data_dir(); + // Escape the path, platform dependent. + std::string path = data_dir(); +#ifdef _WIN32 + // Enclose the path into double quotes on Windows. A quote character is forbidden in file names, + // therefore it does not need to be escaped. + cmd += '"'; + cmd += path; + cmd += '"'; +#else + // Enclose the path into single quotes on Unix / OSX. All single quote characters need to be escaped + // inside a file name. + cmd += '\''; + boost::replace_all(path, "'", "\\'"); + cmd += '\''; +#endif ::wxExecute(wxString::FromUTF8(cmd.c_str()), wxEXEC_ASYNC, nullptr); }