# HG changeset patch # User Mike Becker # Date 1558949257 -7200 # Node ID 8e7f02fd7b9b30d86be2629cf0c25fd21be41acc # Parent 508cbc4d30eacefa5e46f8038d45f63de8a03d11 fixes incorrect URL encoding of the trailing slash for collection names diff -r 508cbc4d30ea -r 8e7f02fd7b9b libidav/session.c --- 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); + } } }