From d1686e18679fd229d2bfa45828a79004cad1e052 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 20 Apr 2022 10:27:18 +0200 Subject: [PATCH] UpdateInfo: Fix parsing of update info It was no longer showing any updates. At some point MaintenanceTool added headers to its responses, which broke our combine-and- parse hack, since such a header in the middle of XML is invalid. Add a hack that removes these headers first. This should be refactored without the use of ShellCommand in master, because that doesn't allow us to access the output of the two jobs separately. Change-Id: I7248b070a8edb1a45248b3531ed50bb0d94eef73 Reviewed-by: Reviewed-by: Christian Stenger --- src/plugins/updateinfo/updateinfotools.h | 8 ++++++-- tests/auto/updateinfo/tst_updateinfo.cpp | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/updateinfo/updateinfotools.h b/src/plugins/updateinfo/updateinfotools.h index 66ad2eb3aca..c8dd3a7fd07 100644 --- a/src/plugins/updateinfo/updateinfotools.h +++ b/src/plugins/updateinfo/updateinfotools.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -40,8 +41,11 @@ Q_DECLARE_LOGGING_CATEGORY(log) std::unique_ptr documentForResponse(const QString &response) { // since the output can contain two toplevel items from the two separate MaintenanceTool runs, - // surround with a toplevel element - const QString xml = response.isEmpty() ? QString() : ("" + response + ""); + // clean up any and surround with a toplevel element + QString responseWithoutHeader = response; + responseWithoutHeader.remove(QRegularExpression("<\\?xml.*\\?>")); + const QString xml = response.isEmpty() ? QString() + : ("" + responseWithoutHeader + ""); std::unique_ptr doc(new QDomDocument); doc->setContent(xml); return doc; diff --git a/tests/auto/updateinfo/tst_updateinfo.cpp b/tests/auto/updateinfo/tst_updateinfo.cpp index 55e61a16c23..1fa1686919b 100644 --- a/tests/auto/updateinfo/tst_updateinfo.cpp +++ b/tests/auto/updateinfo/tst_updateinfo.cpp @@ -45,9 +45,11 @@ void tst_UpdateInfo::updates_data() QTest::addColumn>("xpackages"); QTest::newRow("updates and packages") - << R"raw( + << R"raw( + +