Changeset 6227:bd55d75a1410 in nginx


Ignore:
Timestamp:
08/16/15 07:51:34 (5 years ago)
Author:
Maxim Dounin <mdounin@…>
Branch:
default
Phase:
public
Message:

Fixed wrong URI after try_files in nested location (ticket #97).

The following configuration with alias, nested location and try_files
resulted in wrong file being used. Request "/foo/test.gif" tried to
use "/tmpfoo/test.gif" instead of "/tmp/test.gif":

location /foo/ {

alias /tmp/;
location ~ gif {

try_files $uri =405;

}

}

Additionally, rev. c985d90a8d1f introduced a regression if
the "/tmpfoo/test.gif" file was found (ticket #768). Resulting URI
was set to "gif?/foo/test.gif", as the code used clcf->name of current
location ("location ~ gif") instead of parent one ("location /foo/").

Fix is to use r->uri instead of clcf->name in all cases in the
ngx_http_core_try_files_phase() function. It is expected to be
already matched and identical to the clcf->name of the right
location.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/http/ngx_http_core_module.c

    r6226 r6227  
    12411241
    12421242            if (alias && alias != NGX_MAX_SIZE_T_VALUE
    1243                 && ngx_strncmp(name, clcf->name.data, alias) == 0)
     1243                && ngx_strncmp(name, r->uri.data, alias) == 0)
    12441244            {
    12451245                ngx_memmove(name, name + alias, len - alias);
     
    13251325
    13261326        } else {
     1327            name = r->uri.data;
     1328
    13271329            r->uri.len = alias + path.len;
    13281330            r->uri.data = ngx_pnalloc(r->pool, r->uri.len);
     
    13321334            }
    13331335
    1334             p = ngx_copy(r->uri.data, clcf->name.data, alias);
    1335             ngx_memcpy(p, name, path.len);
     1336            p = ngx_copy(r->uri.data, name, alias);
     1337            ngx_memcpy(p, path.data, path.len);
    13361338        }
    13371339
Note: See TracChangeset for help on using the changeset viewer.