Windows command line parsing: Do escape backslash.
This will break network paths passed as command line arguments.
Introduced by 4ff6951550
.
Task-number: QTBUG-35432
Task-number: QTBUG-30628
Change-Id: Ice9ce15275ef69e9e9e82daf5a303e7c56294368
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
835b821390
commit
7cfe7c1982
@ -101,8 +101,8 @@ static QVector<Char*> qWinCmdLine(Char *cmdParam, int length, int &argc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*p == '\\') { // escape char?
|
if (*p == '\\') { // escape char?
|
||||||
// testing by looking at argc, argv shows that it only escapes quotes and backslashes
|
// testing by looking at argc, argv shows that it only escapes quotes
|
||||||
if (p < p_end && (*(p+1) == Char('\"') || *(p+1) == Char('\\')))
|
if (p < p_end && (*(p+1) == Char('\"')))
|
||||||
p++;
|
p++;
|
||||||
} else {
|
} else {
|
||||||
if (!quote && (*p == Char('\"'))) {
|
if (!quote && (*p == Char('\"'))) {
|
||||||
|
@ -550,15 +550,16 @@ void tst_QCommandLineParser::testQuoteEscaping()
|
|||||||
QProcess process;
|
QProcess process;
|
||||||
process.start("testhelper/qcommandlineparser_test_helper", QStringList() <<
|
process.start("testhelper/qcommandlineparser_test_helper", QStringList() <<
|
||||||
QString::number(QCommandLineParser::ParseAsCompactedShortOptions) <<
|
QString::number(QCommandLineParser::ParseAsCompactedShortOptions) <<
|
||||||
"-DKEY1=\"VALUE1\"" << "-DKEY2=\\\"VALUE2\\\"" <<
|
"\\\\server\\path" <<
|
||||||
|
"-DKEY1=\"VALUE1\""
|
||||||
"-DQTBUG-15379=C:\\path\\'file.ext" <<
|
"-DQTBUG-15379=C:\\path\\'file.ext" <<
|
||||||
"-DQTBUG-30628=C:\\temp\\'file'.ext");
|
"-DQTBUG-30628=C:\\temp\\'file'.ext");
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
QString output = process.readAll();
|
QString output = process.readAll();
|
||||||
QVERIFY2(!output.contains("ERROR"), qPrintable(output));
|
QVERIFY2(!output.contains("ERROR"), qPrintable(output));
|
||||||
|
QVERIFY2(output.contains("\\\\server\\path"), qPrintable(output));
|
||||||
QVERIFY2(output.contains("KEY1=\"VALUE1\""), qPrintable(output));
|
QVERIFY2(output.contains("KEY1=\"VALUE1\""), qPrintable(output));
|
||||||
QVERIFY2(output.contains("KEY2=\\\"VALUE2\\\""), qPrintable(output));
|
|
||||||
QVERIFY2(output.contains("QTBUG-15379=C:\\path\\'file.ext"), qPrintable(output));
|
QVERIFY2(output.contains("QTBUG-15379=C:\\path\\'file.ext"), qPrintable(output));
|
||||||
QVERIFY2(output.contains("QTBUG-30628=C:\\temp\\'file'.ext"), qPrintable(output));
|
QVERIFY2(output.contains("QTBUG-30628=C:\\temp\\'file'.ext"), qPrintable(output));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user