comparison src/http/ngx_http_core_module.c @ 3535:abb3901be800

fix handling an inherited alias in inclusive location
author Igor Sysoev <igor@sysoev.ru>
date Mon, 31 May 2010 14:41:54 +0000
parents 3711bb1336c3
children 64bd39f03182
comparison
equal deleted inserted replaced
3534:3711bb1336c3 3535:abb3901be800
1150 /* suppress MSVC warning */ 1150 /* suppress MSVC warning */
1151 path.data = NULL; 1151 path.data = NULL;
1152 1152
1153 tf = clcf->try_files; 1153 tf = clcf->try_files;
1154 1154
1155 alias = clcf->alias ? clcf->name.len : 0; 1155 alias = clcf->alias;
1156 1156
1157 for ( ;; ) { 1157 for ( ;; ) {
1158 1158
1159 if (tf->lengths) { 1159 if (tf->lengths) {
1160 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); 1160 ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
1754 size_t alias; 1754 size_t alias;
1755 ngx_http_core_loc_conf_t *clcf; 1755 ngx_http_core_loc_conf_t *clcf;
1756 1756
1757 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 1757 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
1758 1758
1759 alias = clcf->alias ? clcf->name.len : 0; 1759 alias = clcf->alias;
1760 1760
1761 if (alias && !r->valid_location) { 1761 if (alias && !r->valid_location) {
1762 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, 1762 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
1763 "\"alias\" could not be used in location \"%V\" " 1763 "\"alias\" could not be used in location \"%V\" "
1764 "where URI was rewritten", &clcf->name); 1764 "where URI was rewritten", &clcf->name);
3602 ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 3602 ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
3603 { 3603 {
3604 ngx_http_core_loc_conf_t *clcf = conf; 3604 ngx_http_core_loc_conf_t *clcf = conf;
3605 3605
3606 ngx_str_t *value; 3606 ngx_str_t *value;
3607 ngx_uint_t alias, n; 3607 ngx_int_t alias;
3608 ngx_uint_t n;
3608 ngx_http_script_compile_t sc; 3609 ngx_http_script_compile_t sc;
3609 3610
3610 alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0; 3611 alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0;
3611 3612
3612 if (clcf->root.data) { 3613 if (clcf->root.data) {
3613 3614
3614 /* the (ngx_uint_t) cast is required by gcc 2.7.2.3 */ 3615 if ((clcf->alias != 0) == alias) {
3615
3616 if ((ngx_uint_t) clcf->alias == alias) {
3617 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3616 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3618 "\"%V\" directive is duplicate", 3617 "\"%V\" directive is duplicate",
3619 &cmd->name); 3618 &cmd->name);
3620 } else { 3619 } else {
3621 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3620 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3657 &cmd->name); 3656 &cmd->name);
3658 3657
3659 return NGX_CONF_ERROR; 3658 return NGX_CONF_ERROR;
3660 } 3659 }
3661 3660
3662 clcf->alias = alias; 3661 clcf->alias = alias ? clcf->name.len : 0;
3663 clcf->root = value[1]; 3662 clcf->root = value[1];
3664 3663
3665 if (!alias && clcf->root.data[clcf->root.len - 1] == '/') { 3664 if (!alias && clcf->root.data[clcf->root.len - 1] == '/') {
3666 clcf->root.len--; 3665 clcf->root.len--;
3667 } 3666 }