diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/nginx.c | 4 | ||||
-rw-r--r-- | src/core/nginx.h | 2 | ||||
-rw-r--r-- | src/core/ngx_string.c | 35 | ||||
-rw-r--r-- | src/core/ngx_string.h | 10 |
4 files changed, 34 insertions, 17 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index d30e12744..a9a0dd905 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -168,6 +168,8 @@ ngx_module_t ngx_core_module = { ngx_uint_t ngx_max_module; +static char *ngx_null_environ = NULL; + int ngx_cdecl main(int argc, char *const *argv) @@ -232,6 +234,8 @@ main(int argc, char *const *argv) return 1; } + environ = &ngx_null_environ; + ngx_max_module = 0; for (i = 0; ngx_modules[i]; i++) { ngx_modules[i]->index = ngx_max_module++; diff --git a/src/core/nginx.h b/src/core/nginx.h index ec125d60e..a2c696fea 100644 --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,7 +8,7 @@ #define _NGINX_H_INCLUDED_ -#define NGINX_VER "nginx/0.3.21" +#define NGINX_VER "nginx/0.3.22" #define NGINX_VAR "NGINX" #define NGX_OLDPID_EXT ".oldbin" diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c index 2bb335a07..c99778d87 100644 --- a/src/core/ngx_string.c +++ b/src/core/ngx_string.c @@ -931,7 +931,7 @@ ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type) void -ngx_unescape_uri(u_char **dst, u_char **src, size_t size) +ngx_unescape_uri(u_char **dst, u_char **src, size_t size, ngx_uint_t type) { u_char *d, *s, ch, c, decoded; enum { @@ -952,7 +952,7 @@ ngx_unescape_uri(u_char **dst, u_char **src, size_t size) switch (state) { case sw_usual: - if (ch == '?') { + if (ch == '?' && type == NGX_UNESCAPE_URI) { *d++ = ch; goto done; } @@ -995,12 +995,18 @@ ngx_unescape_uri(u_char **dst, u_char **src, size_t size) if (ch >= '0' && ch <= '9') { ch = (u_char) ((decoded << 4) + ch - '0'); - if (ch > '%' && ch < 0x7f) { - *d++ = ch; + if (type == NGX_UNESCAPE_URI) { + if (ch > '%' && ch < 0x7f) { + *d++ = ch; + break; + } + + *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1); + break; } - *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1); + *d++ = ch; break; } @@ -1009,17 +1015,22 @@ ngx_unescape_uri(u_char **dst, u_char **src, size_t size) if (c >= 'a' && c <= 'f') { ch = (u_char) ((decoded << 4) + c - 'a' + 10); - if (ch == '?') { - *d++ = ch; - goto done; - } + if (type == NGX_UNESCAPE_URI) { + if (ch == '?') { + *d++ = ch; + goto done; + } + + if (ch > '%' && ch < 0x7f) { + *d++ = ch; + break; + } - if (ch > '%' && ch < 0x7f) { - *d++ = ch; + *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1); break; } - *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1); + *d++ = ch; break; } diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h index 0192a3068..d76a0f555 100644 --- a/src/core/ngx_string.h +++ b/src/core/ngx_string.h @@ -144,13 +144,15 @@ size_t ngx_utf_length(ngx_str_t *utf); u_char * ngx_utf_cpystrn(u_char *dst, u_char *src, size_t n); -#define NGX_ESCAPE_URI 0 -#define NGX_ESCAPE_ARGS 1 -#define NGX_ESCAPE_HTML 2 +#define NGX_ESCAPE_URI 0 +#define NGX_ESCAPE_ARGS 1 +#define NGX_ESCAPE_HTML 2 + +#define NGX_UNESCAPE_URI 1 uintptr_t ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type); -void ngx_unescape_uri(u_char **dst, u_char **src, size_t size); +void ngx_unescape_uri(u_char **dst, u_char **src, size_t size, ngx_uint_t type); #define ngx_qsort qsort |