Mon, 27 May 2019 11:27:37 +0200
fixes incorrect URL encoding of the trailing slash for collection names
libidav/session.c | file | annotate | diff | comparison | revisions |
--- 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); + } } }