# HG changeset patch # User Igor Sysoev # Date 1199390991 0 # Node ID 935427c55e0427f3b8558d554742c2c52e2188bf # Parent 252110065e0ad1f91a401fac03ec2d669a6e9401 test URI/Destination collection/non-collection and Depth diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c --- 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_ 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; + } + + depth = ngx_http_dav_depth(r, NGX_HTTP_DAV_INFINITY_DEPTH); - if (depth != 0 && depth != NGX_HTTP_DAV_INFINITY_DEPTH) { - return NGX_HTTP_BAD_REQUEST; + 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;