src/server/webdav/webdav.c

branch
webdav
changeset 237
ee1680ef1ef2
parent 236
e81d3e517b57
child 239
d5031c30022c
--- a/src/server/webdav/webdav.c	Sun Jan 19 09:31:45 2020 +0100
+++ b/src/server/webdav/webdav.c	Sun Jan 19 10:03:31 2020 +0100
@@ -228,6 +228,7 @@
             sn,
             rq,
             dav,
+            propfind->properties,
             requestObjects,
             response);
     
@@ -414,7 +415,7 @@
     }
     rq->userdata = data;
     
-    data->vfsproperties = webdav_vfs_properties(rq, TRUE, 0);
+    data->vfsproperties = webdav_vfs_properties(outplist, TRUE, 0);
     
     return 0;
 }
@@ -629,7 +630,7 @@
 }
 
 WebdavVFSProperties webdav_vfs_properties(
-        WebdavPropfindRequest *rq,
+        WebdavPList **plistInOut,
         WSBool removefromlist,
         uint32_t flags)
 {
@@ -639,14 +640,13 @@
     WSBool etag = 1;
     WSBool creationdate = 1;
     
-    WebdavPList *property = rq->properties;
-    WebdavPList *prev = NULL;
-    while(property) {
-        WebdavPList *next = property->next;
-        WSNamespace *ns = property->property->namespace;
-        if(ns && !strcmp((char*)ns->href, "DAV:")) {
-            const char *name = property->property->name;
-            WebdavPList *removethis = property;
+    WebdavPListIterator i = webdav_plist_iterator(plistInOut);
+    WebdavPList *cur;
+    while(webdav_plist_iterator_next(&i, &cur)) {
+        WSNamespace *ns = cur->property->namespace;
+        if(ns && !strcmp((const char*)ns->href, "DAV:")) {
+            const char *name = cur->property->name;
+            WSBool remove_prop = TRUE;
             if(!strcmp(name, "getlastmodified")) {
                 ret.getlastmodified = 1;
             } else if(!strcmp(name, "getcontentlength")) {
@@ -658,20 +658,13 @@
             } else if(creationdate && !strcmp(name, "creationdate")) {
                 ret.creationdate = 1;
             } else {
-                removethis = NULL;
+                remove_prop = FALSE;
             }
             
-            if(removefromlist && removethis) {
-                
-                if(prev) {
-                    prev->next = next;
-                } else {
-                    rq->properties = next;
-                }
+            if(remove_prop) {
+                webdav_plist_iterator_remove_current(&i);
             }
         }
-        prev = property;
-        property = next;
     }
     
     return ret;

mercurial