diff options
-rw-r--r-- | src/qml/qml/qqmlfile.cpp | 11 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/{subdir}/Test.qml | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 5 |
3 files changed, 10 insertions, 8 deletions
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp index be9b011dda..6728fa10a7 100644 --- a/src/qml/qml/qqmlfile.cpp +++ b/src/qml/qml/qqmlfile.cpp @@ -666,18 +666,13 @@ QString QQmlFile::urlToLocalFileOrQrc(const QUrl& url) static QString toLocalFile(const QString &url) { - if (!url.startsWith(QLatin1String("file://"), Qt::CaseInsensitive)) + const QUrl file(url); + if (!file.isLocalFile()) return QString(); - QString file = url.mid(7); - //XXX TODO: handle windows hostnames: "//servername/path/to/file.txt" - // magic for drives on windows - if (file.length() > 2 && file.at(0) == QLatin1Char('/') && file.at(2) == QLatin1Char(':')) - file.remove(0, 1); - - return file; + return file.toLocalFile(); } /*! diff --git a/tests/auto/qml/qqmllanguage/data/{subdir}/Test.qml b/tests/auto/qml/qqmllanguage/data/{subdir}/Test.qml new file mode 100644 index 0000000000..f789a905f2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/{subdir}/Test.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +Rectangle { } diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index f48e405dff..78fff58841 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -2210,6 +2210,11 @@ void tst_qqmllanguage::importsLocal_data() "Test {}" << (!qmlCheckTypes()?"TestType":"") << (!qmlCheckTypes()?"":"Test is ambiguous. Found in org/qtproject/Test/ and in subdir/"); + QTest::newRow("file URL survives percent-encoding") + << "import \"" + QUrl::fromLocalFile(QDir::currentPath() + "/{subdir}").toString() + "\"\n" + "Test {}" + << "QQuickRectangle" + << ""; } void tst_qqmllanguage::importsLocal() |