From: Vadim Zeitlin Date: Fri, 18 Jul 2008 22:22:16 +0000 (+0000) Subject: mention compatibility implications of wxExecute() quoting changes; don't change quoti... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a6eac99d9edb1e8fef08780903827c8bad3f9bff mention compatibility implications of wxExecute() quoting changes; don't change quoting of already quoted arguments in 2.8 for compatibility; also fix handling of empty arguments as a side effect (see #4115) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54695 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index 90ff546511..572750c2d8 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -99,6 +99,8 @@ Changes in behaviour not resulting in compilation errors, please read this! your code if you overrode these functions and change the functions in the derived classes to use const reference as well. +- Under MSW wxExecute() arguments are now always properly quoted, as under + Unix, and so shouldn't contain quotes unless they are part of the argument. Changes in behaviour which may result in compilation errors ----------------------------------------------------------- @@ -132,7 +134,7 @@ Changes in behaviour which may result in compilation errors const wxChar*. wxCStrData is implicitly convertible to both "const char *" and "const wchar_t *", so this only presents a problem if the compiler cannot apply the conversion. This can happen in 2 cases: - + + There is an ambiguity because the function being called is overloaded to take both "const char *" and "const wchar_t *" as the compiler can't choose between them. In this case you may use s.wx_str() to call the function @@ -208,7 +210,7 @@ Deprecated methods and their replacements use simpler OnExec() version which is called with wxString argument - wxMenuItem::GetLabel has been deprecated in favour of wxMenuItem::GetItemLabelText - wxMenuItem::GetText has been deprecated in favour of wxMenuItem::GetItemLabel -- wxMenuItem::GetLabelFromText has been deprecated in favour of wxMenuItem::GetLabelText +- wxMenuItem::GetLabelFromText has been deprecated in favour of wxMenuItem::GetLabelText - wxMenuItem::SetText has been deprecated in favour of wxMenuItem::SetItemLabel - wxBrush's, wxPen's SetStyle() and GetStyle() as well as the wxBrush/wxPen ctor now take respectively a wxBrushStyle and a wxPenStyle value instead of a plain "int style"; diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index 7c085553ed..f67e0eb11d 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -1032,16 +1032,28 @@ long wxExecuteImpl(CharType **argv, int flags, wxProcess *handler) { arg = *argv++; - // escape any quotes present in the string to avoid interfering with - // the command line parsing in the child process - arg.Replace("\"", "\\\"", true /* replace all */); + bool quote; + if ( arg.empty() ) + { + // we need to quote empty arguments, otherwise they'd just + // disappear + quote = true; + } + else // non-empty + { + // escape any quotes present in the string to avoid interfering + // with the command line parsing in the child process + arg.Replace("\"", "\\\"", true /* replace all */); - // and quote any arguments containing the spaces to prevent them from - // being broken down - if ( arg.find_first_of(" \t") == wxString::npos ) - command += arg; - else + // and quote any arguments containing the spaces to prevent them from + // being broken down + quote = arg.find_first_of(" \t") != wxString::npos; + } + + if ( quote ) command += '\"' + arg + '\"'; + else + command += arg; if ( !*argv ) break;