[PATCH 1 of 1] Changes in the destination header in MOVE and DELETE methods for files and/or folders

lcolina at cenditel.gob.ve lcolina at cenditel.gob.ve
Wed Sep 11 13:23:09 UTC 2013


# HG changeset patch
# User Laura Colina <lcolina at cenditel.gob.ve>
# Date 1378836243 16200
# Node ID c6e3ea382a3ab5f98350c5810c3ebc080ae0f0ae
# Parent  72e31d88defadc94a17ce208c487aac98632e8f2
Changes in the destination header in MOVE and DELETE methods for files and/or folders

diff -r 72e31d88defa -r c6e3ea382a3a src/http/modules/ngx_http_dav_module.c
--- a/src/http/modules/ngx_http_dav_module.c	Mon Sep 23 19:37:13 2013 +0400
+++ b/src/http/modules/ngx_http_dav_module.c	Tue Sep 10 13:34:03 2013 -0430
@@ -338,10 +338,9 @@
 
     if (ngx_is_dir(&fi)) {
 
-        if (r->uri.data[r->uri.len - 1] != '/') {
-            ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_EISDIR,
-                          "DELETE \"%s\" failed", path.data);
-            return NGX_HTTP_CONFLICT;
+        if (path.data[path.len - 1] == '/') {
+            path.len--;
+            path.data[path.len] = '\0';
         }
 
         depth = ngx_http_dav_depth(r, NGX_HTTP_DAV_INFINITY_DEPTH);
@@ -352,7 +351,7 @@
             return NGX_HTTP_BAD_REQUEST;
         }
 
-        path.len -= 2;  /* omit "/\0" */
+        path.len -= 1;  /* omit "\0" */
 
         dir = 1;
 
@@ -579,6 +578,16 @@
         host = dest->value.data + sizeof("http://") - 1;
     }
 
+    for (p = host; *p!='\0'; p++) {
+        if (*p == '/') {
+           break;
+        }
+        else if (*p == '@') {
+           host = p + 1;
+           break;
+        }
+    }
+
     if (ngx_strncmp(host, r->headers_in.server.data, len) != 0) {
         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                       "\"Destination\" URI \"%V\" is handled by "
@@ -736,10 +745,9 @@
 
     if (ngx_is_dir(&fi)) {
 
-        if (r->uri.data[r->uri.len - 1] != '/') {
-            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
-                          "\"%V\" is collection", &r->uri);
-            return NGX_HTTP_BAD_REQUEST;
+        if (path.data[path.len - 1] == '/') {
+            path.len--;
+            path.data[path.len] = '\0';
         }
 
         if (overwrite) {
@@ -756,7 +764,7 @@
 
     if (ngx_is_dir(&fi)) {
 
-        path.len -= 2;  /* omit "/\0" */
+        path.len -= 1;  /* omit "\0" */
 
         if (r->method == NGX_HTTP_MOVE) {
             if (ngx_rename_file(path.data, copy.path.data) != NGX_FILE_ERROR) {



More information about the nginx-devel mailing list