fixes missing url encoding in dav_session_get_href() with enabled name decryption

Wed, 08 May 2019 19:34:35 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 08 May 2019 19:34:35 +0200
changeset 591
793af8666b3a
parent 590
cda8093116f2
child 592
508cbc4d30ea

fixes missing url encoding in dav_session_get_href() with enabled name decryption

libidav/session.c file | annotate | diff | comparison | revisions
--- a/libidav/session.c	Wed May 08 19:22:06 2019 +0200
+++ b/libidav/session.c	Wed May 08 19:34:35 2019 +0200
@@ -387,6 +387,7 @@
                 
                 ucx_buffer_write(elm.ptr, 1, elm.length, pbuf);
                 if(child) {
+                    // href is already URL encoded, so don't encode again
                     ucx_buffer_puts(href, util_resource_name(child->href));
                     res = child;
                 } else if(DAV_ENCRYPT_NAME(sn)) {
@@ -394,7 +395,12 @@
                     ucx_buffer_puts(href, random_name);
                     free(random_name);
                 } else {
-                    ucx_buffer_puts(href, util_resource_name(path));
+                    // 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);
                 }
             }
             

mercurial