diff options
authorAndy Shaw <andy.shaw@qt.io>2021-03-02 07:54:09 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-09 15:38:05 +0000
commita9061bac004c77b9a6d863854c1635f2a33be7b3 (patch)
parenta06dda1b898ccf4c2fbb947dc55e45c40c3c2772 (diff)
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 <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e0400d08755bb40c303bbe330bc3bd6045436c22) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
1 files changed, 8 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index d473706172..cc640ef3fc 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -1425,11 +1425,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;