aboutsummaryrefslogtreecommitdiff
path: root/src/core/ngx_string.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-06-15 18:33:41 +0000
committerIgor Sysoev <igor@sysoev.ru>2005-06-15 18:33:41 +0000
commitb145b067e296fd0c72d764e36db7a97102045b2c (patch)
tree1604c71100a9ea0dc0be0f848ed7ed9dc7108843 /src/core/ngx_string.c
parente08f105e27475ea77f5ceb39fc76d9cb2ba078d1 (diff)
downloadnginx-release-0.1.36.tar.gz
nginx-release-0.1.36.zip
nginx-0.1.36-RELEASE importrelease-0.1.36
*) Change: if the request header has duplicate the "Host", "Connection", "Content-Length", or "Authorization" lines, then nginx now returns the 400 error. *) Change: the "post_accept_timeout" directive was canceled. *) Feature: the "default", "af=", "bl=", "deferred", and "bind" parameters of the "listen" directive. *) Feature: the FreeBSD accept filters support. *) Feature: the Linux TCP_DEFER_ACCEPT support. *) Bugfix: the ngx_http_autoindex_module did not support the file names in UTF-8. *) Bugfix: the new log file can be rotated by the -USR1 signal only if the reconfiguration by the -HUP signal was made twice.
Diffstat (limited to 'src/core/ngx_string.c')
-rw-r--r--src/core/ngx_string.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c
index acc4bd302..9cbf3c92a 100644
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -728,6 +728,35 @@ ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src)
}
+size_t
+ngx_utf_length(ngx_str_t *utf)
+{
+ u_char c;
+ size_t len;
+ ngx_uint_t i;
+
+ for (len = 0, i = 0; i < utf->len; len++, i++) {
+
+ c = utf->data[i];
+
+ if (c < 0x80) {
+ continue;
+ }
+
+ if (c < 0xC0) {
+ /* invalid utf */
+ return utf->len;
+ }
+
+ for (c <<= 1; c & 0x80; c <<= 1) {
+ i++;
+ }
+ }
+
+ return len;
+}
+
+
uintptr_t
ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type)
{
@@ -792,30 +821,8 @@ 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 */
0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */ };
- /* " ", """, "%", "'", %00-%1F, %7F-%FF */
-
- static uint32_t utf[] =
- { 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
-
- /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
- 0x800000ad, /* 0000 0000 0000 0000 0000 0000 1010 1101 */
-
- /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
- 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
-
- /* ~}| {zyx wvut srqp onml kjih gfed cba` */
- 0x80000000, /* 1000 0000 0000 0000 0000 0000 0000 0000 */
-
- 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
- 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
- 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
- 0x00000000 /* 0000 0000 0000 0000 0000 0000 0000 0000 */ };
-
switch (type) {
- case NGX_ESCAPE_UTF:
- escape = utf;
- break;
case NGX_ESCAPE_HTML:
escape = html;
break;