Utils: Do not use QDir::cleanPath() in FilePath::fromUserInput()

Some of the functionality of QDir::cleanPath() breaks the use of
Creator's variables. For instance, "%{sourceDir}/.." becomes ".".
This has hit us before; see commit 8bc7e04012.
It's not always possible to expand strings before converting them to
FilePath, and it would require a lot of work to change all occurrences
of potentially unexpanded FilePaths to QStrings, so it seems like the
more practical solution to allow unexpanded FilePaths.

Fixes: QTCREATORBUG-24095
Change-Id: I5fbbd181cb888b129f11c120e363228bc52b090a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Kandeler
2020-05-28 15:57:35 +02:00
parent c8d7c074f5
commit 4a6aa35a91

View File

@@ -842,10 +842,10 @@ FilePath FilePath::fromStringWithExtension(const QString &filepath, const QStrin
}
/// Constructs a FilePath from \a filePath
/// \a filePath is only passed through QDir::cleanPath
/// \a filePath is only passed through QDir::fromNativeSeparators
FilePath FilePath::fromUserInput(const QString &filePath)
{
QString clean = QDir::cleanPath(filePath);
QString clean = QDir::fromNativeSeparators(filePath);
if (clean.startsWith(QLatin1String("~/")))
clean = QDir::homePath() + clean.mid(1);
return FilePath::fromString(clean);