diff --git a/docs/changes.txt b/docs/changes.txt index 3034f9def1..2c56e3fccf 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -114,6 +114,7 @@ wxMSW: - Fix keyboard support in wxSpinCtrl broken in 2.8.8. - Compile fix for WinCE in window.cpp (no VkKeyScan in Windows CE). +- Fix quoting of arguments passed to wxExecute(char **) (briis). wxGTK: diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index 6fc80fe856..1237c4d429 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -952,9 +952,22 @@ long wxExecute(wxChar **argv, int flags, wxProcess *handler) { wxString command; + wxString arg; for ( ;; ) { - command += *argv++; + arg = *argv++; + + // escape any quotes present in the string to avoid interfering with + // the command line parsing in the child process + arg.Replace(_T("\""), _T("\\\""), true /* replace all */); + + // and quote any arguments containing the spaces to prevent them from + // being broken down + if ( arg.find_first_of(_T(" \t")) == wxString::npos ) + command += arg; + else + command += _T('\"') + arg + _T('\"'); + if ( !*argv ) break;