diff options
author | Igor Sysoev <igor@sysoev.ru> | 2010-06-07 11:51:37 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2010-06-07 11:51:37 +0000 |
commit | a16387eba9b14d48be0e0644f6030f880b652836 (patch) | |
tree | d8c656540294d47c81a0d46e2cbb5fab566c5fe0 | |
parent | 7fbe27b79f67b44412b061c6ac9b4aaa9f8c1f1a (diff) | |
download | nginx-a16387eba9b14d48be0e0644f6030f880b652836.tar.gz nginx-a16387eba9b14d48be0e0644f6030f880b652836.zip |
merge r3487, r3525:
rewrite fixes:
*) escape ampersand in argument while rewrite
*) autodetect redirect if URI is rewritten to a string starting with $scheme
-rw-r--r-- | src/core/ngx_string.c | 4 | ||||
-rw-r--r-- | src/http/modules/ngx_http_rewrite_module.c | 11 |
2 files changed, 6 insertions, 9 deletions
diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c index f8b165731..9068bd9ea 100644 --- a/src/core/ngx_string.c +++ b/src/core/ngx_string.c @@ -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 */ diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c index 1f98cf829..61090317b 100644 --- a/src/http/modules/ngx_http_rewrite_module.c +++ b/src/http/modules/ngx_http_rewrite_module.c @@ -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; |