Utils: Treat FilePath with variables as user input when expanding

When macro-expanding FilePaths with environment variables, it can happen
that non-conformant path separators end up in the intermediate expanded
string. For example with "%{Env:PROGRAMFILES}" on Windows.

Since we generally treat paths from environment variables as user input,
it makes sense to treat macros as user input as-well in this case.

Change-Id: I0daa57b7dbf3d8fd25c98fb82b2beb1bc6ded825
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Alessandro Portale
2023-05-23 12:45:51 +02:00
parent 0d37a66b51
commit 86ff142f8e

View File

@@ -275,7 +275,7 @@ QString MacroExpander::expand(const QString &stringWithVariables) const
FilePath MacroExpander::expand(const FilePath &fileNameWithVariables) const
{
// We want single variables to expand to fully qualified strings.
return FilePath::fromString(expand(fileNameWithVariables.toString()));
return FilePath::fromUserInput(expand(fileNameWithVariables.toString()));
}
QByteArray MacroExpander::expand(const QByteArray &stringWithVariables) const