mirror of
https://github.com/apache/httpd.git
synced 2026-01-06 09:01:14 +03:00
Followup to r1529559: mod_dav_fs: Fix encoding of hrefs in PROPFIND response.
Previous commit missed encoding the names of the children of the PROPFIND
request when the depth wasn't 0.
* modules/dav/fs/repos.c
(dav_fs_append_uri): New function
(dav_fs_walker): Use dav_fs_append_uri() and adjust length calculations to
use the encoded length.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1531505 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1482,6 +1482,18 @@ static dav_error * dav_fs_remove_resource(dav_resource *resource,
|
||||
return dav_fs_deleteset(info->pool, resource);
|
||||
}
|
||||
|
||||
/* Take an unescaped path component and escape it and append it onto a
|
||||
* dav_buffer for a URI */
|
||||
static apr_size_t dav_fs_append_uri(apr_pool_t *p, dav_buffer *pbuf,
|
||||
const char *path, apr_size_t pad)
|
||||
{
|
||||
const char *epath = ap_escape_uri(p, path);
|
||||
apr_size_t epath_len = strlen(epath);
|
||||
|
||||
dav_buffer_place_mem(p, pbuf, epath, epath_len + 1, pad);
|
||||
return epath_len;
|
||||
}
|
||||
|
||||
/* ### move this to dav_util? */
|
||||
/* Walk recursively down through directories, *
|
||||
* including lock-null resources as we go. */
|
||||
@@ -1537,6 +1549,7 @@ static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)
|
||||
}
|
||||
while ((apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp)) == APR_SUCCESS) {
|
||||
apr_size_t len;
|
||||
apr_size_t escaped_len;
|
||||
|
||||
len = strlen(dirent.name);
|
||||
|
||||
@@ -1579,7 +1592,7 @@ static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)
|
||||
|
||||
/* copy the file to the URI, too. NOTE: we will pad an extra byte
|
||||
for the trailing slash later. */
|
||||
dav_buffer_place_mem(pool, &fsctx->uri_buf, dirent.name, len + 1, 1);
|
||||
escaped_len = dav_fs_append_uri(pool, &fsctx->uri_buf, dirent.name, 1);
|
||||
|
||||
/* if there is a secondary path, then do that, too */
|
||||
if (fsctx->path2.buf != NULL) {
|
||||
@@ -1612,7 +1625,7 @@ static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)
|
||||
fsctx->path2.cur_len += len;
|
||||
|
||||
/* adjust URI length to incorporate subdir and a slash */
|
||||
fsctx->uri_buf.cur_len += len + 1;
|
||||
fsctx->uri_buf.cur_len += escaped_len + 1;
|
||||
fsctx->uri_buf.buf[fsctx->uri_buf.cur_len - 1] = '/';
|
||||
fsctx->uri_buf.buf[fsctx->uri_buf.cur_len] = '\0';
|
||||
|
||||
@@ -1678,8 +1691,8 @@ static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)
|
||||
*/
|
||||
dav_buffer_place_mem(pool, &fsctx->path1,
|
||||
fsctx->locknull_buf.buf + offset, len + 1, 0);
|
||||
dav_buffer_place_mem(pool, &fsctx->uri_buf,
|
||||
fsctx->locknull_buf.buf + offset, len + 1, 0);
|
||||
dav_fs_append_uri(pool, &fsctx->uri_buf,
|
||||
fsctx->locknull_buf.buf + offset, 0);
|
||||
if (fsctx->path2.buf != NULL) {
|
||||
dav_buffer_place_mem(pool, &fsctx->path2,
|
||||
fsctx->locknull_buf.buf + offset,
|
||||
|
||||
Reference in New Issue
Block a user