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( + +