comparison src/http/modules/ngx_http_rewrite_module.c @ 456:ca8f7f6cab16 NGINX_0_7_40

nginx 0.7.40 *) Feature: the "location" directive supports captures in regular expressions. *) Feature: an "alias" directive with capture references may be used inside a location given by a regular expression with captures. *) Feature: the "server_name" directive supports captures in regular expressions. *) Workaround: the ngx_http_autoindex_module did not show the trailing slash in directories on XFS filesystem; the issue had appeared in 0.7.15. Thanks to Dmitry Kuzmenko.
author Igor Sysoev <http://sysoev.ru>
date Mon, 09 Mar 2009 00:00:00 +0300
parents 984bb0b1399b
children f39b9e29530d
comparison
equal deleted inserted replaced
455:ead634c4b006 456:ca8f7f6cab16
10 10
11 11
12 typedef struct { 12 typedef struct {
13 ngx_array_t *codes; /* uintptr_t */ 13 ngx_array_t *codes; /* uintptr_t */
14 14
15 ngx_uint_t captures;
16 ngx_uint_t stack_size; 15 ngx_uint_t stack_size;
17 16
18 ngx_flag_t log; 17 ngx_flag_t log;
19 ngx_flag_t uninitialized_variable_warn; 18 ngx_flag_t uninitialized_variable_warn;
20 } ngx_http_rewrite_loc_conf_t; 19 } ngx_http_rewrite_loc_conf_t;
155 rlcf->stack_size * sizeof(ngx_http_variable_value_t)); 154 rlcf->stack_size * sizeof(ngx_http_variable_value_t));
156 if (e->sp == NULL) { 155 if (e->sp == NULL) {
157 return NGX_HTTP_INTERNAL_SERVER_ERROR; 156 return NGX_HTTP_INTERNAL_SERVER_ERROR;
158 } 157 }
159 158
160 if (rlcf->captures) {
161 e->captures = ngx_palloc(r->pool, rlcf->captures * sizeof(int));
162 if (e->captures == NULL) {
163 return NGX_HTTP_INTERNAL_SERVER_ERROR;
164 }
165
166 } else {
167 e->captures = NULL;
168 }
169
170 e->ip = rlcf->codes->elts; 159 e->ip = rlcf->codes->elts;
171 e->request = r; 160 e->request = r;
172 e->quote = 1; 161 e->quote = 1;
173 e->log = rlcf->log; 162 e->log = rlcf->log;
174 e->status = NGX_DECLINED; 163 e->status = NGX_DECLINED;
434 regex->ncaptures = (ngx_uint_t) n; 423 regex->ncaptures = (ngx_uint_t) n;
435 } 424 }
436 425
437 if (regex->ncaptures) { 426 if (regex->ncaptures) {
438 regex->ncaptures = (regex->ncaptures + 1) * 3; 427 regex->ncaptures = (regex->ncaptures + 1) * 3;
439
440 if (lcf->captures < regex->ncaptures) {
441 lcf->captures = regex->ncaptures;
442 }
443 } 428 }
444 429
445 regex_end = ngx_http_script_add_code(lcf->codes, 430 regex_end = ngx_http_script_add_code(lcf->codes,
446 sizeof(ngx_http_script_regex_end_code_t), 431 sizeof(ngx_http_script_regex_end_code_t),
447 &regex); 432 &regex);
616 if (rv != NGX_CONF_OK) { 601 if (rv != NGX_CONF_OK) {
617 return rv; 602 return rv;
618 } 603 }
619 604
620 605
621 if (lcf->captures < nlcf->captures) {
622 lcf->captures = nlcf->captures;
623 }
624
625
626 if (elts != lcf->codes->elts) { 606 if (elts != lcf->codes->elts) {
627 if_code = (ngx_http_script_if_code_t *) 607 if_code = (ngx_http_script_if_code_t *)
628 ((u_char *) if_code + ((u_char *) lcf->codes->elts - elts)); 608 ((u_char *) if_code + ((u_char *) lcf->codes->elts - elts));
629 } 609 }
630 610
775 755
776 n = ngx_regex_capture_count(regex->regex); 756 n = ngx_regex_capture_count(regex->regex);
777 757
778 if (n) { 758 if (n) {
779 regex->ncaptures = (n + 1) * 3; 759 regex->ncaptures = (n + 1) * 3;
780
781 if (lcf->captures < regex->ncaptures) {
782 lcf->captures = regex->ncaptures;
783 }
784 } 760 }
785 761
786 return NGX_CONF_OK; 762 return NGX_CONF_OK;
787 } 763 }
788 764