Tue, 22 Mar 2016 11:24:14 +0100
fixed lazy propfind parser
libidav/methods.c | file | annotate | diff | comparison | revisions | |
libidav/methods.h | file | annotate | diff | comparison | revisions |
--- a/libidav/methods.c Mon Mar 21 16:37:10 2016 +0100 +++ b/libidav/methods.c Tue Mar 22 11:24:14 2016 +0100 @@ -377,10 +377,8 @@ if(n->type == XML_ELEMENT_NODE) { properties = ucx_list_append(properties, n); if(xstreq(n->name, "resourcetype")) { - xmlNode *rsnode = n->children; - if(rsnode && rsnode->type == XML_ELEMENT_NODE) { - // TODO: check content - iscollection = 1; + if(parse_resource_type(n)) { + iscollection = TRUE; } } else if(xstreq(n->ns->href, DAV_NS)) { if(xstreq(n->name, "crypto-name")) { @@ -612,11 +610,8 @@ if(n->type == XML_ELEMENT_NODE) { properties = ucx_list_append(properties, n); if(xstreq(n->name, "resourcetype")) { - xmlNode *rsnode = n->children; - if(rsnode && rsnode->type == XML_ELEMENT_NODE) { - // TODO: this is a ugly lazy hack - //resource_add_property(res, "DAV:", (char*)n->name, "collection"); - iscollection = 1; + if(parse_resource_type(n)) { + iscollection = TRUE; } } else if(xstreq(n->ns->href, DAV_NS)) { if(xstreq(n->name, "crypto-name")) { @@ -704,6 +699,21 @@ res->lastmodified = util_parse_lastmodified(lm); } +int parse_resource_type(xmlNode *node) { + int collection = FALSE; + xmlNode *c = node->children; + while(c) { + if(c->type == XML_ELEMENT_NODE) { + if(xstreq(c->ns->href, "DAV:") && xstreq(c->name, "collection")) { + collection = TRUE; + break; + } + } + c = c->next; + } + return collection; +} + /* ----------------------------- PROPPATCH ----------------------------- */
--- a/libidav/methods.h Mon Mar 21 16:37:10 2016 +0100 +++ b/libidav/methods.h Tue Mar 22 11:24:14 2016 +0100 @@ -96,6 +96,12 @@ int parse_response_tag(DavResource *resource, xmlNode *node); void set_davprops(DavResource *res); +/* + * parses the content of a resourcetype element + * returns 1 if the resourcetype is a collection, 0 otherwise + */ +int parse_resource_type(xmlNode *node); + UcxBuffer* create_proppatch_request(DavResourceData *data); UcxBuffer* create_crypto_proppatch_request(DavSession *sn, DavKey *key, char *name, char *hash);