aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.h2
-rw-r--r--src/core/ngx_inet.h1
-rw-r--r--src/core/ngx_string.c74
-rw-r--r--src/core/ngx_string.h3
4 files changed, 73 insertions, 7 deletions
diff --git a/src/core/nginx.h b/src/core/nginx.h
index cd1917fec..834a4c895 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.49"
+#define NGINX_VER "nginx/0.3.50"
#define NGINX_VAR "NGINX"
#define NGX_OLDPID_EXT ".oldbin"
diff --git a/src/core/ngx_inet.h b/src/core/ngx_inet.h
index 25f923230..7600ed801 100644
--- a/src/core/ngx_inet.h
+++ b/src/core/ngx_inet.h
@@ -99,7 +99,6 @@ typedef struct {
unsigned uri_part:1;
unsigned port_only:1;
- unsigned virtual:1;
} ngx_inet_upstream_t;
diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c
index 6a81984dd..3716df661 100644
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -750,16 +750,82 @@ ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src)
}
+/*
+ * ngx_utf_decode() decodes two and more bytes UTF sequences only
+ * the return values:
+ * 0x80 - 0x10ffff valid character
+ * 0x10ffff - 0xfffffffd invalid sequence
+ * 0xfffffffe incomplete sequence
+ * 0xffffffff error
+ */
+
+uint32_t
+ngx_utf_decode(u_char **p, size_t n)
+{
+ size_t len;
+ uint32_t u, i, valid;
+
+ u = **p;
+
+ if (u > 0xf0) {
+
+ u &= 0x07;
+ valid = 0xffff;
+ len = 3;
+
+ } else if (u > 0xe0) {
+
+ u &= 0x0f;
+ valid = 0x7ff;
+ len = 2;
+
+ } else if (u > 0xc0) {
+
+ u &= 0x1f;
+ valid = 0x7f;
+ len = 1;
+
+ } else {
+ (*p)++;
+ return 0xffffffff;
+ }
+
+ if (n - 1 < len) {
+ return 0xfffffffe;
+ }
+
+ (*p)++;
+
+ while (len) {
+ i = *(*p)++;
+
+ if (i < 0x80) {
+ return 0xffffffff;
+ }
+
+ u = (u << 6) | (i & 0x3f);
+
+ len--;
+ }
+
+ if (u > valid) {
+ return u;
+ }
+
+ return 0xffffffff;
+}
+
+
size_t
-ngx_utf_length(ngx_str_t *utf)
+ngx_utf_length(u_char *p, size_t n)
{
u_char c;
size_t len;
ngx_uint_t i;
- for (len = 0, i = 0; i < utf->len; len++, i++) {
+ for (len = 0, i = 0; i < n; len++, i++) {
- c = utf->data[i];
+ c = p[i];
if (c < 0x80) {
continue;
@@ -775,7 +841,7 @@ ngx_utf_length(ngx_str_t *utf)
/* invalid utf */
- return utf->len;
+ return n;
}
return len;
diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h
index 818a290d1..10f87ae93 100644
--- a/src/core/ngx_string.h
+++ b/src/core/ngx_string.h
@@ -146,7 +146,8 @@ void ngx_md5_text(u_char *text, u_char *md5);
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);
+uint32_t ngx_utf_decode(u_char **p, size_t n);
+size_t ngx_utf_length(u_char *p, size_t n);
u_char * ngx_utf_cpystrn(u_char *dst, u_char *src, size_t n);