AndroidDeployQt: explitly constuct the qmlDomCommand args list

Construct the arguments list explicilty to QStringList to avoid calling
QProcess::splitCommand() and potentially splitting a path with spaces
that shouldn't, this also saves from having to deal with shell quotes.

Fixes: QTBUG-132891
Pick-to: 6.8
Change-Id: I48f6c219830269c507f146b654bcfa025f0e3203
Reviewed-by: Olli Vuolteenaho <olli.vuolteenaho@qt.io>
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Soheil Armin <soheil.armin@qt.io>
(cherry picked from commit a8d8fb83ccfed09dd35dbab22caceaff963a3415)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Assam Boudjelthia 2025-01-17 13:36:09 +02:00 committed by Qt Cherry-pick Bot
parent 87330d4bd7
commit 10b88f3f20

View File

@ -3611,17 +3611,14 @@ int generateJavaQmlComponents(const Options &options)
const QString &qmlFile,
const QStringList &otherImportPaths) -> QJsonObject {
QByteArray domInfo;
QString importFlags;
for (auto &importPath : otherImportPaths)
importFlags.append(" -I %1"_L1.arg(shellQuote(importPath)));
const QString qmlDomCmd = "%1 -d -D required -f +:propertyInfos %2 %3"_L1.arg(
shellQuote(qmlDomExecPath), importFlags,
shellQuote("%1/%2"_L1.arg(qmldirPath, qmlFile)));
#if QT_CONFIG(process)
const QStringList qmlDomCmdParts = QProcess::splitCommand(qmlDomCmd);
QStringList qmlDomArgs {"-d"_L1, "-D"_L1, "required"_L1, "-f"_L1, "+:propertyInfos"_L1 };
for (auto &importPath : otherImportPaths)
qmlDomArgs << "-I"_L1 << importPath;
qmlDomArgs << "%1/%2"_L1.arg(qmldirPath, qmlFile);
const QString qmlDomCmd = "%1 %2"_L1.arg(qmlDomExecPath, qmlDomArgs.join(u' '));
QProcess process;
process.start(qmlDomCmdParts.first(), qmlDomCmdParts.sliced(1));
process.start(qmlDomExecPath, qmlDomArgs);
if (!process.waitForStarted()) {
fprintf(stderr, "Cannot execute command %s\n", qPrintable(qmlDomCmd));
return QJsonObject();