]> git.kaiwu.me - nginx.git/commitdiff
Fixed config parsing of the last try_files parameter.
authorSergey Kandaurov <pluknet@nginx.com>
Wed, 28 May 2014 16:18:05 +0000 (20:18 +0400)
committerSergey Kandaurov <pluknet@nginx.com>
Wed, 28 May 2014 16:18:05 +0000 (20:18 +0400)
Do not taste the last parameter against directory, as otherwise it would
result in the trailing slash being cut from the parameter value.

Notably, this prevents an internal redirect to an empty URI
if the parameter is set to the literal slash:

    location / { try_files $uri /; }

src/http/ngx_http_core_module.c

index 741a80d9313a093e5f1c617586a36c8b0bc39ca9..fb02dd465042c04673006979b99f7b2c478222f1 100644 (file)
@@ -4789,7 +4789,8 @@ ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
         tf[i].name = value[i + 1];
 
         if (tf[i].name.len > 0
-            && tf[i].name.data[tf[i].name.len - 1] == '/')
+            && tf[i].name.data[tf[i].name.len - 1] == '/'
+            && i + 2 < cf->args->nelts)
         {
             tf[i].test_dir = 1;
             tf[i].name.len--;