summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-07-03 09:25:53 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-07-03 14:55:47 +0200
commitb79b9e35334b3bdd41329f2ea74bc82f3f05ae52 (patch)
tree9cd483260c969e370c54306c1c4c5a088bc0df41
parent75ba1ce9114e320cccfbc0c14dd32675ce2e598e (diff)
downloadqtdeclarative-b79b9e35334b3bdd41329f2ea74bc82f3f05ae52.tar.gz
Create a URL from the import string before adding the qmldir path
Otherwise the path might get interpreted as some other part of the URL, for example the host name. Fixes: QTBUG-76441 Change-Id: I3edde96153403962db4576e5af794419c21b49a8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/qml/qqmltypeloader.cpp6
-rw-r--r--tests/auto/qml/qqmltypeloader/data/qrcRootPath.qml4
-rw-r--r--tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp8
3 files changed, 17 insertions, 1 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index df6a8f1500..9e5bc0b021 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -1495,7 +1495,11 @@ bool QQmlTypeLoader::Blob::addImport(const QV4::CompiledData::Import *import, QL
bool incomplete = false;
- QUrl qmldirUrl = finalUrl().resolved(QUrl(importUri + QLatin1String("/qmldir")));
+ QUrl importUrl(importUri);
+ QString path = importUrl.path();
+ path.append(QLatin1String(path.endsWith(QLatin1Char('/')) ? "qmldir" : "/qmldir"));
+ importUrl.setPath(path);
+ QUrl qmldirUrl = finalUrl().resolved(importUrl);
if (!QQmlImports::isLocal(qmldirUrl)) {
// This is a remote file; the import is currently incomplete
incomplete = true;
diff --git a/tests/auto/qml/qqmltypeloader/data/qrcRootPath.qml b/tests/auto/qml/qqmltypeloader/data/qrcRootPath.qml
new file mode 100644
index 0000000000..bdbee4eb59
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/qrcRootPath.qml
@@ -0,0 +1,4 @@
+import QtQml 2.12
+import "qrc:/"
+
+QtObject {}
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
index 0c4abf19f4..52c722aac8 100644
--- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
+++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
@@ -56,6 +56,7 @@ private slots:
void qmlSingletonWithinModule();
void multiSingletonModule();
void implicitComponentModule();
+ void qrcRootPathUrl();
};
void tst_QQMLTypeLoader::testLoadComplete()
@@ -503,6 +504,13 @@ void tst_QQMLTypeLoader::implicitComponentModule()
checkCleanCacheLoad(QLatin1String("implicitComponentModule"));
}
+void tst_QQMLTypeLoader::qrcRootPathUrl()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("qrcRootPath.qml"));
+ QCOMPARE(component.status(), QQmlComponent::Ready);
+}
+
QTEST_MAIN(tst_QQMLTypeLoader)
#include "tst_qqmltypeloader.moc"