diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2024-05-16 15:53:23 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-05-17 17:34:33 +0200 |
commit | 9b784345795984878d2938d6903e7c87ae7f0778 (patch) | |
tree | 4487dfbde5b1f49a7969f5ddc7b7279c63ff54b9 /tests/auto/qml | |
parent | 6cd080a4143f61b83388fff4aede534d085b6db1 (diff) |
qmlcompiler: Sanitize qmldir paths before using them
They may contain backslashes.
Pick-to: 6.7 6.5
Fixes: QTBUG-125393
Change-Id: Ifd8c97c44b036ab64a221775a7fe6316445f6cf8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r-- | tests/auto/qml/qmllint/data/something.qml | 2 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/qml/qmllint/data/something.qml b/tests/auto/qml/qmllint/data/something.qml new file mode 100644 index 0000000000..38998f606d --- /dev/null +++ b/tests/auto/qml/qmllint/data/something.qml @@ -0,0 +1,2 @@ +import ModuleInImportPath +A {} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index a9b5f8d732..bcccd5f1f0 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -105,6 +105,7 @@ private Q_SLOTS: void valueTypesFromString(); void ignoreSettingsNotCommandLineOptions(); + void backslashedQmldirPath(); void environment_data(); void environment(); @@ -113,6 +114,7 @@ private Q_SLOTS: void testPlugin(); void quickPlugin(); #endif + private: enum DefaultImportOption { NoDefaultImports, UseDefaultImports }; enum ContainOption { StringNotContained, StringContained }; @@ -2253,5 +2255,14 @@ void TestQmllint::ignoreSettingsNotCommandLineOptions() QCOMPARE(output, QString()); } +void TestQmllint::backslashedQmldirPath() +{ + const QString qmldirPath + = testFile(u"ImportPath/ModuleInImportPath/qmldir"_s).replace('/', QDir::separator()); + const QString output = runQmllint( + testFile(u"something.qml"_s), true, QStringList{ u"-i"_s, qmldirPath }); + QVERIFY(output.isEmpty()); +} + QTEST_GUILESS_MAIN(TestQmllint) #include "tst_qmllint.moc" |