]> git.mxchange.org Git - simgear.git/commitdiff
Check for DAV status parse failures.
authorJames Turner <zakalawe@mac.com>
Sat, 5 Oct 2013 22:23:13 +0000 (23:23 +0100)
committerJames Turner <zakalawe@mac.com>
Wed, 9 Oct 2013 08:03:26 +0000 (10:03 +0200)
simgear/io/DAVMultiStatus.cxx
simgear/io/DAVMultiStatus.hxx
simgear/io/SVNRepository.cxx

index 53b34b673791a8483bd2dc2afcd8b4dea748fd79..a805a214a5a4b76056ff28d00fe4b075be0152e1 100644 (file)
@@ -183,7 +183,8 @@ class DAVMultiStatus::DAVMultiStatusPrivate
 {
 public:
   DAVMultiStatusPrivate() :
-  parserInited(false)
+      parserInited(false),
+      valid(false)
   {
     rootResource = NULL;
   }
@@ -287,6 +288,7 @@ public:
   }
   
   bool parserInited;
+  bool valid;
   XML_Parser xmlParser;
   DAVResource* rootResource;
   
@@ -366,13 +368,21 @@ void DAVMultiStatus::parseXML(const char* data, int size)
     
     XML_ParserFree(_d->xmlParser);
     _d->parserInited = false;
+    _d->valid = false;
   }
 }
 
 void DAVMultiStatus::finishParse()
 {
   if (_d->parserInited) {
-    XML_Parse(_d->xmlParser, NULL, 0, true);
+    if (!XML_Parse(_d->xmlParser, NULL, 0, true)) {
+        SG_LOG(SG_IO, SG_WARN, "DAV parse error:" << XML_ErrorString(XML_GetErrorCode(_d->xmlParser))
+               << " at line:" << XML_GetCurrentLineNumber(_d->xmlParser)
+               << " column " << XML_GetCurrentColumnNumber(_d->xmlParser));
+        _d->valid = false;
+    } else {
+        _d->valid = true;
+    }
     XML_ParserFree(_d->xmlParser);
   }
   
@@ -384,4 +394,9 @@ DAVResource* DAVMultiStatus::resource()
   return _d->rootResource;
 }
 
+bool DAVMultiStatus::isValid() const
+{
+    return _d->valid;
+}
+
 
index 862bf9d0df2cd5e3f99303a473065cc44a3a0dd9..d415e5ae8513d25ae4ff0e25c3d9ecfb93d8382a 100644 (file)
@@ -129,6 +129,8 @@ public:
     
     void finishParse();
     
+    bool isValid() const;
+    
     DAVResource* resource();
   
   class DAVMultiStatusPrivate;
index 62173ff9c15eea8a1b07b2d1efde3fd7a75ced81..b74df28c2954b67140086a81757c04044979ae81 100644 (file)
@@ -173,7 +173,11 @@ namespace { // anonmouse
       {
         if (responseCode() == 207) {
           _davStatus.finishParse();
-          _repo->propFindComplete(this, (DAVCollection*) _davStatus.resource());
+          if (_davStatus.isValid()) {
+              _repo->propFindComplete(this, (DAVCollection*) _davStatus.resource());
+          } else {
+              _repo->propFindFailed(this, SVNRepository::SVN_ERROR_SOCKET);
+          }
         }
       }