forked from qt-creator/qt-creator
Utils: clean file name before creating fs engine
Change-Id: I9c4c8132ad509820e0388787ab34bf11b3c4465b Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -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
|
||||
|
@@ -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"
|
||||
|
Reference in New Issue
Block a user