changeset 3344:1aed55182ea2

fix captures in "rewrite", the bug had been introduced in r3326
author Igor Sysoev <igor@sysoev.ru>
date Mon, 16 Nov 2009 19:10:45 +0000
parents 3051e512e301
children d8228f0b5113
files src/http/ngx_http_script.c src/http/ngx_http_variables.c
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -910,14 +910,14 @@ ngx_http_script_regex_start_code(ngx_htt
         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 {
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -1810,7 +1810,7 @@ ngx_http_regex_exec(ngx_http_request_t *
 #endif
     }
 
-    r->ncaptures = len;
+    r->ncaptures = rc * 2;
     r->captures_data = s->data;
 
     return NGX_OK;