diff --git a/src/libs/utils/filepath.cpp b/src/libs/utils/filepath.cpp index 0197b146c1c..08f26ba7af9 100644 --- a/src/libs/utils/filepath.cpp +++ b/src/libs/utils/filepath.cpp @@ -821,8 +821,13 @@ void FilePath::setRootAndPath(QStringView path, OsType osType) m_root = "/"; m_path = path.mid(1).toString(); } else if (path.startsWith(':')) { - m_root = ":/"; - m_path = path.mid(2).toString(); + if (path.length() > 1 && path[1] == '/') { + m_root = ":/"; + m_path = path.mid(2).toString(); + } else { + m_root = ":"; + m_path = path.mid(1).toString(); + } } else { m_root.clear(); m_path = path.toString(); diff --git a/tests/auto/utils/fileutils/tst_fileutils.cpp b/tests/auto/utils/fileutils/tst_fileutils.cpp index bcf6dc58a8c..b92d9996155 100644 --- a/tests/auto/utils/fileutils/tst_fileutils.cpp +++ b/tests/auto/utils/fileutils/tst_fileutils.cpp @@ -350,6 +350,10 @@ void tst_fileutils::fromString_data() QTest::addColumn("osType"); QTest::newRow("empty") << "" << "" << "" << "" << HostOsInfo::hostOs(); + QTest::newRow("single-slash") << ":" << "" << "" << ":" << HostOsInfo::hostOs(); + QTest::newRow("single-colon") << "/" << "" << "" << "/" << HostOsInfo::hostOs(); + QTest::newRow("single-char") << "a" << "" << "" << "a" << HostOsInfo::hostOs(); + QTest::newRow("qrc-no-slash") << ":test.txt" << "" << "" << ":test.txt" << HostOsInfo::hostOs(); QTest::newRow("qrc") << ":/test.txt" << "" << "" << ":/test.txt" << HostOsInfo::hostOs(); QTest::newRow("unc-incomplete") << "//" << "" << "" << "" << OsType::OsTypeWindows; QTest::newRow("unc-incomplete-only-server") << "//server" << "" << "" << "//server/" << OsType::OsTypeWindows;