]> git.kaiwu.me - nginx.git/commitdiff
merge r3487, r3525:
authorIgor Sysoev <igor@sysoev.ru>
Mon, 7 Jun 2010 11:51:37 +0000 (11:51 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Mon, 7 Jun 2010 11:51:37 +0000 (11:51 +0000)
rewrite fixes:

*) escape ampersand in argument while rewrite
*) autodetect redirect if URI is rewritten to a string starting with $scheme

src/core/ngx_string.c
src/http/modules/ngx_http_rewrite_module.c

index f8b1657310ea5fcfe2f64f19fb557bfe972cc8df..9068bd9ea5a1e77e23177995dee2f0501eaaa509 100644 (file)
@@ -1277,13 +1277,13 @@ ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type)
         0xffffffff  /* 1111 1111 1111 1111  1111 1111 1111 1111 */
     };
 
-                    /* " ", "#", "%", "+", "?", %00-%1F, %7F-%FF */
+                    /* " ", "#", "%", "&", "+", "?", %00-%1F, %7F-%FF */
 
     static uint32_t   args[] = {
         0xffffffff, /* 1111 1111 1111 1111  1111 1111 1111 1111 */
 
                     /* ?>=< ;:98 7654 3210  /.-, +*)( '&%$ #"!  */
-        0x80000829, /* 1000 0000 0000 0000  0000 1000 0010 1001 */
+        0x80000869, /* 1000 0000 0000 0000  0000 1000 0110 1001 */
 
                     /* _^]\ [ZYX WVUT SRQP  ONML KJIH GFED CBA@ */
         0x00000000, /* 0000 0000 0000 0000  0000 0000 0000 0000 */
index 1f98cf829562bed2268ea88a588d29395c30796d..61090317baab833412f96bf377bb6af2e8dbe5cf 100644 (file)
@@ -340,13 +340,10 @@ ngx_http_rewrite(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
     last = 0;
 
-    if (ngx_strncmp(value[2].data, "http://", sizeof("http://") - 1) == 0) {
-        regex->status = NGX_HTTP_MOVED_TEMPORARILY;
-        regex->redirect = 1;
-        last = 1;
-    }
-
-    if (ngx_strncmp(value[2].data, "https://", sizeof("https://") - 1) == 0) {
+    if (ngx_strncmp(value[2].data, "http://", sizeof("http://") - 1) == 0
+        || ngx_strncmp(value[2].data, "https://", sizeof("https://") - 1) == 0
+        || ngx_strncmp(value[2].data, "$scheme", sizeof("$scheme") - 1) == 0)
+    {
         regex->status = NGX_HTTP_MOVED_TEMPORARILY;
         regex->redirect = 1;
         last = 1;