From 5dadc57bc38c3be45970b7ff3bf8088ecb0a92ab Mon Sep 17 00:00:00 2001 From: Burak Hancerli Date: Mon, 5 Jun 2023 14:11:03 +0200 Subject: [PATCH] QmlProject: Fix escaping while rewriting the qmlproject file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QDS-10032 Change-Id: I856d9935a1c77085f79008db19920f12af9e1a21 Reviewed-by: Henning Gründl Reviewed-by: --- .../buildsystem/projectitem/converters.cpp | 6 ++++-- tests/unit/unittest/qmlprojectmanager/converters-test.cpp | 6 ++++++ .../data/converter/test-set-1/testfile.jsontoqml | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmlprojectmanager/buildsystem/projectitem/converters.cpp b/src/plugins/qmlprojectmanager/buildsystem/projectitem/converters.cpp index 98dd4cea983..7f01e33f435 100644 --- a/src/plugins/qmlprojectmanager/buildsystem/projectitem/converters.cpp +++ b/src/plugins/qmlprojectmanager/buildsystem/projectitem/converters.cpp @@ -156,7 +156,9 @@ QString jsonToQmlProject(const QJsonObject &rootObject) { // append ShaderTool object if (!shaderConfig["args"].toVariant().toStringList().isEmpty()) { startObject("ShaderTool"); - appendString("args", shaderConfig["args"].toVariant().toStringList().join(" ")); + appendString("args", + shaderConfig["args"].toVariant().toStringList().join(" ").replace( + "\"", "\\\"")); appendArray("files", shaderConfig["files"].toVariant().toStringList()); endObject(); } @@ -193,7 +195,7 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile) } if (rootNode->name() != QLatin1String("Project")) { - qCritical() << "Cannot find root 'Proejct' item in the project file: " << projectFile; + qCritical() << "Cannot find root 'Project' item in the project file: " << projectFile; return {}; } diff --git a/tests/unit/unittest/qmlprojectmanager/converters-test.cpp b/tests/unit/unittest/qmlprojectmanager/converters-test.cpp index 4e4e225a890..b985fff53d3 100644 --- a/tests/unit/unittest/qmlprojectmanager/converters-test.cpp +++ b/tests/unit/unittest/qmlprojectmanager/converters-test.cpp @@ -31,12 +31,14 @@ public: ? QString::fromLatin1(m_qmlProjectFile.fileContents().value()) : QString{}); } + QString jsonToQmlProjectContent() const { return m_jsonToQmlProjectFile.fileContents() ? QString::fromLatin1(m_jsonToQmlProjectFile.fileContents().value()) : QString{}; } + QString qmlProjectToJsonContent() const { return m_qmlProjectToJsonFile.fileContents() @@ -45,9 +47,13 @@ public: } QString dataSetPath() const { return m_dataSetDirectory.absolutePath(); } + QString dataSetName() const { return m_dataSetDirectory.dirName(); } + Utils::FilePath qmlProjectFile() const { return m_qmlProjectFile; } + Utils::FilePath jsonToQmlProjectFile() const { return m_jsonToQmlProjectFile; } + Utils::FilePath qmlProjectToJsonFile() const { return m_qmlProjectToJsonFile; } private: diff --git a/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-1/testfile.jsontoqml b/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-1/testfile.jsontoqml index fe2c378c705..dbd6e4a91ac 100644 --- a/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-1/testfile.jsontoqml +++ b/tests/unit/unittest/qmlprojectmanager/data/converter/test-set-1/testfile.jsontoqml @@ -28,7 +28,7 @@ Project { } ShaderTool { - args: "-s --glsl "100 es,120,150" --hlsl 50 --msl 12" + args: "-s --glsl \"100 es,120,150\" --hlsl 50 --msl 12" files: [ "content/shaders/*" ] }