summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-06-30 19:04:24 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-04 16:06:04 +0200
commitb929ce465f3e9121f0fa3beffa184413c05f9216 (patch)
tree85f17b026060206bf957694f422a26bba7863eac /src
parenta77ce3301c2035a2aaa3c14e051dceb46ca27924 (diff)
fix argument quoting on windows
quotes prefixed with multiple backslashes would not be escaped correctly. Change-Id: I56ec72e31bb4ed2b9119ec1996448f803f89ce35 Reviewed-on: http://codereview.qt.nokia.com/962 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
Diffstat (limited to 'src')
-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 1761c0edee..dba3de47a7 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.