diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/nginx.h | 2 | ||||
-rw-r--r-- | src/core/ngx_connection.h | 1 | ||||
-rw-r--r-- | src/core/ngx_palloc.c | 2 | ||||
-rw-r--r-- | src/core/ngx_string.c | 54 | ||||
-rw-r--r-- | src/core/ngx_string.h | 2 |
5 files changed, 53 insertions, 8 deletions
diff --git a/src/core/nginx.h b/src/core/nginx.h index f9f1a061b..221ba38f0 100644 --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,7 +8,7 @@ #define _NGINX_H_INCLUDED_ -#define NGINX_VER "nginx/0.1.37" +#define NGINX_VER "nginx/0.1.38" #define NGINX_VAR "NGINX" #define NGX_NEWPID_EXT ".newbin" diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h index 0224d98dd..10a5cd587 100644 --- a/src/core/ngx_connection.h +++ b/src/core/ngx_connection.h @@ -128,6 +128,7 @@ struct ngx_connection_s { unsigned single_connection:1; unsigned unexpected_eof:1; unsigned timedout:1; + unsigned closed:1; unsigned sendfile:1; unsigned sndlowat:1; diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c index e7c888285..9bb50f79c 100644 --- a/src/core/ngx_palloc.c +++ b/src/core/ngx_palloc.c @@ -15,7 +15,7 @@ ngx_create_pool(size_t size, ngx_log_t *log) p = ngx_alloc(size, log); if (p == NULL) { - return NULL; + return NULL; } p->last = (u_char *) p + sizeof(ngx_pool_t); diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c index e21a9fcdd..575e60e84 100644 --- a/src/core/ngx_string.c +++ b/src/core/ngx_string.c @@ -753,20 +753,62 @@ ngx_utf_length(ngx_str_t *utf) continue; } - if (c < 0xC0) { - /* invalid utf */ - return utf->len; - } + if (c >= 0xc0) { + for (c <<= 1; c & 0x80; c <<= 1) { + i++; + } - for (c <<= 1; c & 0x80; c <<= 1) { - i++; + continue; } + + /* invalid utf */ + + return utf->len; } return len; } +u_char * +ngx_utf_cpystrn(u_char *dst, u_char *src, size_t n) +{ + u_char c; + + if (n == 0) { + return dst; + } + + for ( /* void */ ; --n; dst++, src++) { + + c = *src; + *dst = c; + + if (c < 0x80) { + if (*dst != '\0') { + continue; + } + + return dst; + } + + if (c >= 0xc0) { + for (c <<= 1; c & 0x80; c <<= 1) { + *++dst = *++src; + } + + continue; + } + + /* invalid utf */ + } + + *dst = '\0'; + + return dst; +} + + uintptr_t ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type) { diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h index ff21619ae..545c6cc85 100644 --- a/src/core/ngx_string.h +++ b/src/core/ngx_string.h @@ -97,6 +97,8 @@ void ngx_encode_base64(ngx_str_t *dst, ngx_str_t *src); ngx_int_t ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src); 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 |