fix captures in "rewrite", the bug had been introduced in r3326

This commit is contained in:
Igor Sysoev 2009-11-16 19:10:45 +00:00
parent 93da565962
commit d86a0bfed4
2 changed files with 4 additions and 4 deletions

View File

@ -910,14 +910,14 @@ ngx_http_script_regex_start_code(ngx_http_script_engine_t *e)
e->buf.len = code->size;
if (code->uri) {
if (rc && (r->quoted_uri || r->plus_in_uri)) {
if (r->ncaptures && (r->quoted_uri || r->plus_in_uri)) {
e->buf.len += 2 * ngx_escape_uri(NULL, r->uri.data, r->uri.len,
NGX_ESCAPE_ARGS);
}
}
for (n = 1; n < (ngx_uint_t) rc; n++) {
e->buf.len += r->captures[2 * n + 1] - r->captures[2 * n];
for (n = 2; n < r->ncaptures; n += 2) {
e->buf.len += r->captures[n + 1] - r->captures[n];
}
} else {

View File

@ -1810,7 +1810,7 @@ ngx_http_regex_exec(ngx_http_request_t *r, ngx_http_regex_t *re, ngx_str_t *s)
#endif
}
r->ncaptures = len;
r->ncaptures = rc * 2;
r->captures_data = s->data;
return NGX_OK;