src/server/plugins/postgresql/webdav.c

branch
webdav
changeset 324
44cf877b3d9f
parent 318
60870dbac94f
child 331
ab26980faad6
--- a/src/server/plugins/postgresql/webdav.c	Sun May 01 11:14:47 2022 +0200
+++ b/src/server/plugins/postgresql/webdav.c	Sun May 01 12:33:48 2022 +0200
@@ -598,7 +598,12 @@
                     property->value.text.str = content;
                     property->value.text.length = pvalue_len;
                 } else {
-                    // TODO
+                    WebdavNSList *nslist = wsxml_string2nslist(pool, nsdef); 
+                    property->vtype = WS_VALUE_XML_DATA;
+                    property->value.data->data = content;
+                    property->value.data->length = pvalue_len;
+                    property->value.data->namespaces = nslist;
+                    
                 }
             }
             
@@ -731,12 +736,20 @@
     // convert the property value to WSXmlData
     // property->vtype == WS_VALUE_XML_NODE should always be true
     WSXmlData *property_value = property->vtype == WS_VALUE_XML_NODE ? wsxml_node2data(pool, property->value.node) : NULL;
-    char *value_str = property_value ? property_value->data : NULL;
-
-    // TODO: convert WebdavNSList to a string
+    char *value_str = NULL;
+    char *nsdef_str = NULL;
+    if(property_value) {
+        value_str = property_value->data;
+        if(property_value->namespaces) {
+            nsdef_str = wsxml_nslist2string(pool, property_value->namespaces);
+            if(!nsdef_str) {
+                return 1; // OOM
+            }
+        }
+    }
 
     // exec sql
-    const char* params[7] = { resource_id_str, (const char*)ns->prefix, (const char*)ns->href, property->name, NULL, NULL, value_str}; 
+    const char* params[7] = { resource_id_str, (const char*)ns->prefix, (const char*)ns->href, property->name, NULL, nsdef_str, value_str}; 
     PGresult *result = PQexecParams(
         pgdav->connection,
         sql_proppatch_set,

mercurial