diff --git a/src/libs/utils/fsengine/fsenginehandler.cpp b/src/libs/utils/fsengine/fsenginehandler.cpp index c5aba915d35..84c9b082f87 100644 --- a/src/libs/utils/fsengine/fsenginehandler.cpp +++ b/src/libs/utils/fsengine/fsenginehandler.cpp @@ -47,10 +47,7 @@ QAbstractFileEngine *FSEngineHandler::create(const QString &fileName) const static const FilePath rootFilePath = FilePath::specialFilePath(FilePath::SpecialPathComponent::RootPath); - QString fixedFileName = fileName; - - if (fileName.startsWith("//")) - fixedFileName = fixedFileName.mid(1); + const QString fixedFileName = QDir::cleanPath(fileName); if (fixedFileName == rootPath) { const FilePaths paths diff --git a/tests/auto/utils/fsengine/tst_fsengine.cpp b/tests/auto/utils/fsengine/tst_fsengine.cpp index 48969c40176..a32575094bc 100644 --- a/tests/auto/utils/fsengine/tst_fsengine.cpp +++ b/tests/auto/utils/fsengine/tst_fsengine.cpp @@ -50,6 +50,7 @@ private slots: void testCreateDir(); void testWindowsPaths(); void testUrl(); + void testBrokenWindowsPath(); private: QString makeTestPath(QString path, bool asUrl = false); @@ -290,5 +291,18 @@ void tst_fsengine::testUrl() QVERIFY(p.needsDevice()); } +void tst_fsengine::testBrokenWindowsPath() +{ + QTemporaryFile tmp; + QVERIFY(tmp.open()); + + QString localFileName = tmp.fileName(); + localFileName.insert(HostOsInfo::isWindowsHost() ? 2 : 0, '/'); + + QFile file(localFileName); + QVERIFY(file.open(QIODevice::ReadOnly)); + QCOMPARE(tmp.fileName(), QFileInfo(localFileName).canonicalFilePath()); +} + QTEST_GUILESS_MAIN(tst_fsengine) #include "tst_fsengine.moc"