From 58d04fe3fa3b20c2c046bda2d70e4d2112885665 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Thu, 3 Jan 2008 20:09:51 +0000 Subject: [PATCH] test URI/Destination collection/non-collection and Depth --- src/http/modules/ngx_http_dav_module.c | 30 ++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c index 4056232eb..94867aa5e 100644 --- a/src/http/modules/ngx_http_dav_module.c +++ b/src/http/modules/ngx_http_dav_module.c @@ -631,7 +631,7 @@ ngx_http_dav_copy_move_handler(ngx_http_request_t *r) if (ngx_strncmp(desthost, host->value.data, len) != 0) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, - "Destination URI \"%V\" is handled by " + "\"Destination\" URI \"%V\" is handled by " "different repository than the source URI", &dest->value); return NGX_HTTP_BAD_REQUEST; @@ -654,10 +654,32 @@ invalid_destination: destination_done: - depth = ngx_http_dav_depth(r, 0); + if ((r->uri.data[r->uri.len - 1] == '/' && *(last - 1) != '/') + || (r->uri.data[r->uri.len - 1] != '/' && *(last - 1) == '/')) + { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "both URI \"%V\" and \"Destination\" URI \"%V\" " + "should be either collections or non-collections", + &r->uri, &dest->value); + return NGX_HTTP_CONFLICT; + } - if (depth != 0 && depth != NGX_HTTP_DAV_INFINITY_DEPTH) { - return NGX_HTTP_BAD_REQUEST; + depth = ngx_http_dav_depth(r, NGX_HTTP_DAV_INFINITY_DEPTH); + + if (depth != NGX_HTTP_DAV_INFINITY_DEPTH) { + + if (r->method == NGX_HTTP_COPY) { + if (depth != 0) { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "\"Depth\" header must be 0 or infinity"); + return NGX_HTTP_BAD_REQUEST; + } + + } else { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "\"Depth\" header must be infinity"); + return NGX_HTTP_BAD_REQUEST; + } } over = r->headers_in.overwrite;