[Pkg-owncloud-commits] [owncloud-client] 131/332: Networkjobs: Check if reply body is empty before parsing.

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:06:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit d2436ce23de73241029285b1d2824b3172498cfc
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Tue Jun 24 15:17:33 2014 +0200

    Networkjobs: Check if reply body is empty before parsing.
    
    This avoids a false warning that the result is not valid JSON.
---
 src/mirall/networkjobs.cpp | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/mirall/networkjobs.cpp b/src/mirall/networkjobs.cpp
index 4276245..7034f14 100644
--- a/src/mirall/networkjobs.cpp
+++ b/src/mirall/networkjobs.cpp
@@ -408,20 +408,25 @@ bool CheckServerJob::finished()
     }
 
     bool success = false;
-    QVariantMap status = QtJson::parse(QString::fromUtf8(reply()->readAll()), success).toMap();
-    // empty or invalid response
-    if (!success || status.isEmpty()) {
-        qDebug() << "status.php from server is not valid JSON!";
-    }
-
-    qDebug() << "status.php returns: " << status << " " << reply()->error() << " Reply: " << reply();
-    if( status.contains("installed")
-            && status.contains("version")
-            && status.contains("versionstring") ) {
-        emit instanceFound(reply()->url(), status);
-    } else {
-        qDebug() << "No proper answer on " << requestedUrl;
+    QByteArray body = reply()->readAll();
+    if( body.isEmpty() ) {
         emit instanceNotFound(reply());
+    } else {
+        QVariantMap status = QtJson::parse(QString::fromUtf8(body), success).toMap();
+        // empty or invalid response
+        if (!success || status.isEmpty()) {
+            qDebug() << "status.php from server is not valid JSON!";
+        }
+
+        qDebug() << "status.php returns: " << status << " " << reply()->error() << " Reply: " << reply();
+        if( status.contains("installed")
+                && status.contains("version")
+                && status.contains("versionstring") ) {
+            emit instanceFound(reply()->url(), status);
+        } else {
+            qDebug() << "No proper answer on " << requestedUrl;
+            emit instanceNotFound(reply());
+        }
     }
     return true;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list