Check for DAV status parse failures.

This commit is contained in:
James Turner 2013-10-05 23:23:13 +01:00
parent 7fdf42b699
commit 0bd82a43d3
3 changed files with 24 additions and 3 deletions

View 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;
}

View File

@ -129,6 +129,8 @@ public:
void finishParse();
bool isValid() const;
DAVResource* resource();
class DAVMultiStatusPrivate;

View 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);
}
}
}