From 4b19cdeca035df36baffdc9cfb61052bf2f64543 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Thu, 17 Mar 2016 10:29:35 +0100 Subject: [PATCH] Propfind: Treat broken XML response as failure #4575 Soldiering on with a broken or incomplete response could lead to incorrect sync behavior. Since discovery uses LsCol jobs which already handle errors correctly, this should not have a significant impact. --- src/libsync/abstractnetworkjob.cpp | 2 +- src/libsync/networkjobs.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libsync/abstractnetworkjob.cpp b/src/libsync/abstractnetworkjob.cpp index 60ac96f99a..e1a654b9ea 100644 --- a/src/libsync/abstractnetworkjob.cpp +++ b/src/libsync/abstractnetworkjob.cpp @@ -265,7 +265,7 @@ QString extractErrorMessage(const QByteArray& errorResponse) } QString exception; - while (!reader.atEnd() && reader.error() == QXmlStreamReader::NoError) { + while (!reader.atEnd() && !reader.hasError()) { reader.readNextStartElement(); if (reader.name() == QLatin1String("message")) { QString message = reader.readElementText(); diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 58550b2803..09472be877 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -558,7 +558,12 @@ bool PropfindJob::finished() } } } - emit result(items); + if (reader.hasError()) { + qDebug() << "PROPFIND request XML parser error: " << reader.errorString(); + emit finishedWithError(reply()); + } else { + emit result(items); + } } else { qDebug() << "PROPFIND request *not* successful, http result code is" << http_result_code << (http_result_code == 302 ? reply()->header(QNetworkRequest::LocationHeader).toString() : QLatin1String(""));