From f88c885d447cba42ea929bbe02324fefe23af038 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 27 Sep 2021 22:12:34 +0200 Subject: [PATCH] McuSupport: FilePath::fromString -> fromUserInput changes Prevent non-portable dir delimiters from getting into a FilePath. Change-Id: I78e4a98e03ffe95e3cef70c9c499af28fa33c25c Reviewed-by: Reviewed-by: hjk --- src/plugins/mcusupport/mcusupportoptions.cpp | 3 ++- src/plugins/mcusupport/mcusupportversiondetection.cpp | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/mcusupport/mcusupportoptions.cpp b/src/plugins/mcusupport/mcusupportoptions.cpp index ea7c8acac1c..6fa37d5a83b 100644 --- a/src/plugins/mcusupport/mcusupportoptions.cpp +++ b/src/plugins/mcusupport/mcusupportoptions.cpp @@ -1305,7 +1305,8 @@ Tasks McuDependenciesKitAspect::validate(const Kit *k) const if (!environment.hasKey(dependency.name)) { result << BuildSystemTask(Task::Warning, tr("Environment variable %1 not defined.").arg(dependency.name)); } else { - const auto path = Utils::FilePath::fromString(environment.value(dependency.name) + "/" + dependency.value); + const auto path = Utils::FilePath::fromUserInput( + environment.value(dependency.name) + "/" + dependency.value); if (!path.exists()) { result << BuildSystemTask(Task::Warning, tr("%1 not found.").arg(path.toUserOutput())); } diff --git a/src/plugins/mcusupport/mcusupportversiondetection.cpp b/src/plugins/mcusupport/mcusupportversiondetection.cpp index 1266202ef84..de94cc01fe2 100644 --- a/src/plugins/mcusupport/mcusupportversiondetection.cpp +++ b/src/plugins/mcusupport/mcusupportversiondetection.cpp @@ -62,14 +62,13 @@ QString McuPackageExecutableVersionDetector::parseVersion(const QString &package if (m_detectionPath.isEmpty() || m_detectionRegExp.isEmpty()) return QString(); - QString binaryPath = QDir::toNativeSeparators(packagePath + "/" + m_detectionPath); - if (!Utils::FilePath::fromString(binaryPath).exists()) + const Utils::FilePath binaryPath = Utils::FilePath::fromString(packagePath) / m_detectionPath; + if (!binaryPath.exists()) return QString(); - const int execTimeout = 3000; // usually runs below 1s, but we want to be on the safe side QProcess binaryProcess; - binaryProcess.start(binaryPath, m_detectionArgs); + binaryProcess.start(binaryPath.toString(), m_detectionArgs); if (!binaryProcess.waitForStarted()) return QString(); binaryProcess.waitForFinished(execTimeout);