]> git.kaiwu.me - nginx.git/commitdiff
fix captures in "rewrite", the bug had been introduced in r3326
authorIgor Sysoev <igor@sysoev.ru>
Mon, 16 Nov 2009 19:10:45 +0000 (19:10 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Mon, 16 Nov 2009 19:10:45 +0000 (19:10 +0000)
src/http/ngx_http_script.c
src/http/ngx_http_variables.c

index b809e2b981b8995a375f120940043a8b0023d411..aa03df00752016f8d603013592189c68661a2a38 100644 (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 {
index 633b31084afb09b3505eaa30a9322cd210eaca82..0289a64ac555456f3ee348fc53157bf40b39aef0 100644 (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;