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
This commit is contained in:
Vadim Zeitlin
2008-07-18 22:22:16 +00:00
parent 8a9e5d8590
commit a6eac99d9e
2 changed files with 24 additions and 10 deletions

View File

@@ -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;