From ce9386db8f34b78b295d9f0d975df0a7822274f7 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 2 Mar 2021 07:54:09 +0100 Subject: Ensure that the case of the path will match then QUrl for a UNC path When a UNC path is used to locate the qmldir then when it is checked later on the original path will be compared against the one that QUrl returns. However, QUrl will convert the case of the host name to be all lower-case whereas the original string may have been in upper-case. For example, QUrl::fromLocalFile("//QT-L-R90X9VHB/tasks").toString() will output "file://qt-l-r90x9vhb/tasks". So in this case, the absoluteFilePath is changed at this point so that it will match what QUrl has for the same path to avoid a problem with it no being found. Change-Id: I2cd5d74bfec06c01635f80574ac1a6d479792855 Reviewed-by: Ulf Hermann Reviewed-by: Fabian Kosmale (cherry picked from commit e0400d08755bb40c303bbe330bc3bd6045436c22) Reviewed-by: Qt Cherry-pick Bot --- src/qml/qml/qqmlimport.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index a6a8c54845..6592bfa6c6 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1420,11 +1420,16 @@ QQmlImports::LocalQmldirResult QQmlImportsPrivate::locateLocalQmldir( if (!absoluteFilePath.isEmpty()) { QString url; const QStringView absolutePath = QStringView{absoluteFilePath}.left(absoluteFilePath.lastIndexOf(Slash) + 1); - if (absolutePath.at(0) == Colon) + if (absolutePath.at(0) == Colon) { url = QLatin1String("qrc") + absolutePath; - else + } else { url = QUrl::fromLocalFile(absolutePath.toString()).toString(); - + // This handles the UNC path case as when the path is retrieved from the QUrl it + // will convert the host name from upper case to lower case. So the absoluteFilePath + // is changed at this point to make sure it will match later on in that case. + if (absoluteFilePath.startsWith(QLatin1String("//"))) + absoluteFilePath = QUrl::fromLocalFile(absoluteFilePath).toString(QUrl::RemoveScheme); + } QQmlImportDatabase::QmldirCache *cache = new QQmlImportDatabase::QmldirCache; cache->version = version; cache->qmldirFilePath = absoluteFilePath; -- cgit v1.2.3