summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-06-30 17:04:24 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-07-13 15:54:53 (GMT)
commit8226f869250a67e33e1f3b5ddba73975c85b6794 (patch)
tree89d8a00e4c6eb9e46b9a156ff3c5ac1138b30971 /src/corelib
parentb955efd392d2c1ec82a043df7b364af71e464078 (diff)
downloadQt-8226f869250a67e33e1f3b5ddba73975c85b6794.zip
Qt-8226f869250a67e33e1f3b5ddba73975c85b6794.tar.gz
Qt-8226f869250a67e33e1f3b5ddba73975c85b6794.tar.bz2
fix argument quoting on windows
quotes prefixed with multiple backslashes would not be escaped correctly.
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qprocess_win.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 1761c0e..dba3de4 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -46,6 +46,7 @@
#include <qdatetime.h>
#include <qdir.h>
#include <qfileinfo.h>
+#include <qregexp.h>
#include <qtimer.h>
#include <qthread.h>
#include <qmutex.h>
@@ -256,10 +257,8 @@ static QString qt_create_commandline(const QString &program, const QStringList &
for (int i=0; i<arguments.size(); ++i) {
QString tmp = arguments.at(i);
- // in the case of \" already being in the string the \ must also be escaped
- tmp.replace( QLatin1String("\\\""), QLatin1String("\\\\\"") );
- // escape a single " because the arguments will be parsed
- tmp.replace( QLatin1Char('\"'), QLatin1String("\\\"") );
+ // Quotes are escaped and their preceding backslashes are doubled.
+ tmp.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\""));
if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
// The argument must not end with a \ since this would be interpreted
// as escaping the quote -- rather put the \ behind the quote: e.g.