diff options
author | David Faure <david.faure@kdab.com> | 2013-09-07 18:17:12 -0400 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-10 19:05:19 +0200 |
commit | 4ff6951550cb6e39c3b31895c3af57037e90c9ac (patch) | |
tree | 5161e3cd21c69474409575acc2356faf3c59235b /src/corelib/kernel/qcorecmdlineargs_p.h | |
parent | ad46d5b82b1bc4ce931b62907cd41356de294f5a (diff) |
Fix escape handling in qWinCmdArgs
-DKEY="VALUE" was correctly turned into -DKEY=VALUE,
but -DKEY=\"VALUE\" was turned into -DKEY=\VALUE"
due to the erroneous check ('quote' is still 0 when
encountering the first '\' character).
This fixes QCoreApplication::arguments() as used by
moc.exe after porting to QCommandLineParser.
Further investigation shows that double-quotes and single-quotes
are handled differently. The tests now ensure that this parser
respects what Windows sends in argv, and in particular that
QTBUG-15379 doesn't regress, as well as fixing QTBUG-30628.
Task-number: QTBUG-15379, QTBUG-30628
Change-Id: I95062c9a6022632b321b2f6fae3089f07be7b5c6
Reviewed-by: Richard J. Moore <rich@kde.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qcorecmdlineargs_p.h')
-rw-r--r-- | src/corelib/kernel/qcorecmdlineargs_p.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/kernel/qcorecmdlineargs_p.h b/src/corelib/kernel/qcorecmdlineargs_p.h index 17a03a5b2d..f2b109facd 100644 --- a/src/corelib/kernel/qcorecmdlineargs_p.h +++ b/src/corelib/kernel/qcorecmdlineargs_p.h @@ -83,7 +83,7 @@ static QVector<Char*> qWinCmdLine(Char *cmdParam, int length, int &argc) if (*p && p < p_end) { // arg starts int quote; Char *start, *r; - if (*p == Char('\"') || *p == Char('\'')) { // " or ' quote + if (*p == Char('\"')) { quote = *p; start = ++p; } else { @@ -101,10 +101,11 @@ static QVector<Char*> qWinCmdLine(Char *cmdParam, int length, int &argc) } } if (*p == '\\') { // escape char? - if (*(p+1) == quote) + // testing by looking at argc, argv shows that it only escapes quotes and backslashes + if (p < p_end && (*(p+1) == Char('\"') || *(p+1) == Char('\\'))) p++; } else { - if (!quote && (*p == Char('\"') || *p == Char('\''))) { // " or ' quote + if (!quote && (*p == Char('\"'))) { quote = *p++; continue; } else if (QChar((short)(*p)).isSpace() && !quote) |