comparison src/core/ngx_string.c @ 72:b31656313b59 NGINX_0_1_36

nginx 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.
author Igor Sysoev <http://sysoev.ru>
date Wed, 15 Jun 2005 00:00:00 +0400
parents 8ad297c88dcb
children 77969b24f355
comparison
equal deleted inserted replaced
71:66f1f40f29d6 72:b31656313b59
726 726
727 return NGX_OK; 727 return NGX_OK;
728 } 728 }
729 729
730 730
731 size_t
732 ngx_utf_length(ngx_str_t *utf)
733 {
734 u_char c;
735 size_t len;
736 ngx_uint_t i;
737
738 for (len = 0, i = 0; i < utf->len; len++, i++) {
739
740 c = utf->data[i];
741
742 if (c < 0x80) {
743 continue;
744 }
745
746 if (c < 0xC0) {
747 /* invalid utf */
748 return utf->len;
749 }
750
751 for (c <<= 1; c & 0x80; c <<= 1) {
752 i++;
753 }
754 }
755
756 return len;
757 }
758
759
731 uintptr_t 760 uintptr_t
732 ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type) 761 ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type)
733 { 762 {
734 ngx_uint_t i, n; 763 ngx_uint_t i, n;
735 uint32_t *escape; 764 uint32_t *escape;
790 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 819 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
791 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 820 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
792 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 821 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
793 0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */ }; 822 0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */ };
794 823
795 /* " ", """, "%", "'", %00-%1F, %7F-%FF */
796
797 static uint32_t utf[] =
798 { 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
799
800 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
801 0x800000ad, /* 0000 0000 0000 0000 0000 0000 1010 1101 */
802
803 /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
804 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
805
806 /* ~}| {zyx wvut srqp onml kjih gfed cba` */
807 0x80000000, /* 1000 0000 0000 0000 0000 0000 0000 0000 */
808
809 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
810 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
811 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
812 0x00000000 /* 0000 0000 0000 0000 0000 0000 0000 0000 */ };
813
814 824
815 switch (type) { 825 switch (type) {
816 case NGX_ESCAPE_UTF:
817 escape = utf;
818 break;
819 case NGX_ESCAPE_HTML: 826 case NGX_ESCAPE_HTML:
820 escape = html; 827 escape = html;
821 break; 828 break;
822 case NGX_ESCAPE_ARGS: 829 case NGX_ESCAPE_ARGS:
823 escape = args; 830 escape = args;