From 2c4595ad02ff35011c24ea71c193d5a9710bec30 Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Tue, 19 Jun 2012 10:24:01 +1000 Subject: Decode directory separators in source URLs URLs with encoded directory-separator characters are not correctly processed by QUrl. Task-number: QTBUG-25981 Change-Id: I78173ef44c4850774b56753335bea34db04c0735 Reviewed-by: Chris Adams --- tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 3 ++- tests/auto/quick/qquickloader/data/subdir/Test.qml | 5 +++++ tests/auto/quick/qquickloader/tst_qquickloader.cpp | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/auto/quick/qquickloader/data/subdir/Test.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 248cc0d803..658874f46d 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -1557,11 +1557,12 @@ void tst_qqmlproperty::urlHandling_data() << QString("/main.qml") << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now%20working?"); + // Although 'text%2Fqml' is pre-encoded, it will be decoded to allow correct QUrl classification QTest::newRow("preencodedQuery") << QByteArray("http://www.example.com/main.qml?type=text%2Fqml&comment=now working%3F") << QString("http") << QString("/main.qml") - << QByteArray("http://www.example.com/main.qml?type=text%2Fqml&comment=now%20working%3F"); + << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now%20working%3F"); QTest::newRow("encodableFragment") << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000|volume+50%") diff --git a/tests/auto/quick/qquickloader/data/subdir/Test.qml b/tests/auto/quick/qquickloader/data/subdir/Test.qml new file mode 100644 index 0000000000..3abbd89d46 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/subdir/Test.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + id: test +} diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index dfe02c649f..dc21af89d7 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -201,6 +201,10 @@ void tst_QQuickLoader::sourceOrComponent_data() QTest::addColumn("errorString"); QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << testFileUrl("Rect120x60.qml") << ""; + QTest::newRow("source with subdir") << "source" << "source: 'subdir/Test.qml'\n" << testFileUrl("subdir/Test.qml") << ""; + QTest::newRow("source with encoded subdir literal") << "source" << "source: 'subdir%2fTest.qml'\n" << testFileUrl("subdir/Test.qml") << ""; + QTest::newRow("source with encoded subdir optimized binding") << "source" << "source: 'subdir' + '%2fTest.qml'\n" << testFileUrl("subdir/Test.qml") << ""; + QTest::newRow("source with encoded subdir binding") << "source" << "source: encodeURIComponent('subdir/Test.qml')\n" << testFileUrl("subdir/Test.qml") << ""; QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << ""; QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << testFileUrl("IDontExist.qml") << QString(testFileUrl("IDontExist.qml").toString() + ": File not found"); -- cgit v1.2.3