diff -r 49adcbd7d473 -r 3c23855f7b46 src/server/webdav/multistatus.c --- a/src/server/webdav/multistatus.c Thu Jan 16 22:28:22 2020 +0100 +++ b/src/server/webdav/multistatus.c Fri Jan 17 17:42:10 2020 +0100 @@ -117,6 +117,7 @@ int status) { MSResponse *response = (MSResponse*)res; + Session *sn = response->multistatus->sn; if(response->resource.isclosed) { log_ereport( LOG_WARN, @@ -135,18 +136,9 @@ property->name); return 1; } - if(property->nsdef) { - // error: nsdef MUST be NULL, only fill nsdef in this func - log_ereport( - LOG_FAILURE, - "%s", - "webdav: property '%s': nsdef must be null", - property->name); - return 1; - } // check if the property was already added to the resource - UcxAllocator *a = session_get_allocator(response->multistatus->sn); + UcxAllocator *a = session_get_allocator(sn); sstr_t key = sstrcat_a( a, 3, @@ -162,97 +154,20 @@ } a->free(a->pool, key.ptr); - // add namespace of this property to the namespace map - // the namespace map will be used for global namespace definitions - if(property->namespace->prefix) { - char *ns = ucx_map_cstr_get( - response->multistatus->namespaces, - (const char*)property->namespace->prefix); - if(!ns) { - // prefix is not in use -> we can add the namespace to the ns map - int err = ucx_map_cstr_put( - response->multistatus->namespaces, - (const char*)property->namespace->prefix, - property->namespace->href); - if(err) { - return 1; // OOM - } - } else if(strcmp((char*)property->namespace->href, ns)) { - // global namespace != local namespace - // therefore we need a namespace definition in this element - - if(webdav_property_add_nsdef( - property, - response->multistatus->sn->pool, - (const char*)property->namespace->prefix, - (const char*)property->namespace->href)) - { - return 1; // OOM - } - } - } - // error properties will be added to a separate list if(status != 200) { return msresponse_addproperror(response, property, status); } - // add all namespaces used by this property to the nsdef list - WebdavNSList *nslist = NULL; - if(property->vtype == WS_VALUE_XML_NODE) { - // iterate over xml tree and collect all namespaces - int err = 0; - WebdavNSList *nsdef = wsxml_get_required_namespaces( - response->multistatus->sn->pool, - property->value.node, - &err); - if(err) { - return 1; // OOM - } - nslist = nsdef; - } else if(property->vtype == WS_VALUE_XML_DATA) { - // xml data contains a list of all used namespaces - nslist = property->value.data->namespaces; - } // other value types don't contain xml namespaces - - while(nslist) { - // only add the namespace to the definitions list, if it isn't a - // property namespace, because the prop ns is already added - // to the element's def list or global definitions list - if(strcmp( - (const char*)nslist->namespace->prefix, - (const char*)property->namespace->prefix)) - { - // ns-prefix != property-prefix -> add ns to nsdef - if(webdav_property_add_nsdef( - property, - response->multistatus->sn->pool, - (const char*)nslist->namespace->prefix, - (const char*)nslist->namespace->href)) - { - return 1; // OOM - } - } - nslist = nslist->next; - } - // add property to the list - WebdavPList *listelm = pool_malloc( - response->multistatus->sn->pool, - sizeof(WebdavPList)); - if(!listelm) { + if(webdav_plist_add( + sn->pool, + &response->plist_begin, + &response->plist_end, + property)) + { return 1; } - - listelm->property = property; - listelm->next = NULL; - - if(response->plist_end) { - response->plist_end->next = listelm; - } else { - response->plist_begin = listelm; - } - response->plist_end = listelm; return 0; }