libidav/session.c

changeset 600
8e7f02fd7b9b
parent 591
793af8666b3a
child 601
1fbca22dd700
--- a/libidav/session.c	Sun May 12 13:49:36 2019 +0200
+++ b/libidav/session.c	Mon May 27 11:27:37 2019 +0200
@@ -397,10 +397,20 @@
                 } else {
                     // path is not URL encoded, so we have to do this here
                     scstr_t resname = scstr(util_resource_name(path));
-                    char *esc = curl_easy_escape(sn->handle,
-                            resname.ptr, resname.length);
-                    ucx_buffer_write(esc, 1, strlen(esc), href);
-                    curl_free(esc);
+                    // the name of collections ends with
+                    // a trailing slash, which MUST NOT be encoded
+                    if(resname.ptr[resname.length-1] == '/') {
+                        char *esc = curl_easy_escape(sn->handle,
+                                resname.ptr, resname.length-1);
+                        ucx_buffer_write(esc, 1, strlen(esc), href);
+                        ucx_buffer_putc(href, '/');
+                        curl_free(esc);
+                    } else  {
+                        char *esc = curl_easy_escape(sn->handle,
+                                resname.ptr, resname.length);
+                        ucx_buffer_write(esc, 1, strlen(esc), href);
+                        curl_free(esc);
+                    }
                 }
             }
             

mercurial