Fix parsing propstat blocks

There can be more than one propstat block each with their own status code. We're only interested in the one with the 200 status, the found properties. This fixes parsing to make sure we process all propstat blocks instead of just the last one, which might have a 404 status for not-found properties. Signed-off-by: 's avatarVincent Petry <PVince81@yahoo.fr>
parent 687788e4
......@@ -243,6 +243,7 @@ class PropfindOperation : BlockingHttpRequest, CommonExpatParser {
enum class State {
ROOT,
RESPONSE,
PROPSTAT,
HREF,
STATUS,
TYPE,
......@@ -322,9 +323,13 @@ private:
break;
case State::RESPONSE:
if (strcmp(name, "DAV:|href") == 0)
if (strcmp(name, "DAV:|propstat") == 0)
state = State::PROPSTAT;
else if (strcmp(name, "DAV:|href") == 0)
state = State::HREF;
else if (strcmp(name, "DAV:|status") == 0)
break;
case State::PROPSTAT:
if (strcmp(name, "DAV:|status") == 0)
state = State::STATUS;
else if (strcmp(name, "DAV:|resourcetype") == 0)
state = State::TYPE;
......@@ -354,9 +359,15 @@ private:
case State::RESPONSE:
if (strcmp(name, "DAV:|response") == 0) {
FinishResponse();
state = State::ROOT;
}
break;
case State::PROPSTAT:
if (strcmp(name, "DAV:|propstat") == 0) {
FinishResponse();
state = State::RESPONSE;
}
break;
......@@ -367,22 +378,22 @@ private:
case State::STATUS:
if (strcmp(name, "DAV:|status") == 0)
state = State::RESPONSE;
state = State::PROPSTAT;
break;
case State::TYPE:
if (strcmp(name, "DAV:|resourcetype") == 0)
state = State::RESPONSE;
state = State::PROPSTAT;
break;
case State::MTIME:
if (strcmp(name, "DAV:|getlastmodified") == 0)
state = State::RESPONSE;
state = State::PROPSTAT;
break;
case State::LENGTH:
if (strcmp(name, "DAV:|getcontentlength") == 0)
state = State::RESPONSE;
state = State::PROPSTAT;
break;
}
}
......@@ -390,6 +401,7 @@ private:
void CharacterData(const XML_Char *s, int len) final {
switch (state) {
case State::ROOT:
case State::PROPSTAT:
case State::RESPONSE:
case State::TYPE:
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment