comparison src/core/ngx_string.c @ 601:77f77f53214a release-0.3.22

nginx-0.3.22-RELEASE import *) Feature: the ngx_http_perl_module supports the $r->args and $r->unescape methods. *) Feature: the method $r->query_string of ngx_http_perl_module was canceled. *) Bugfix: segmentation fault was occurred if the "none" or "blocked" values was specified in the "valid_referers" directive; the bug had appeared in 0.3.18.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 17 Jan 2006 20:04:32 +0000
parents d4e858a5751a
children c73c5c58c619
comparison
equal deleted inserted replaced
600:2d3a5a03e738 601:77f77f53214a
929 return (uintptr_t) dst; 929 return (uintptr_t) dst;
930 } 930 }
931 931
932 932
933 void 933 void
934 ngx_unescape_uri(u_char **dst, u_char **src, size_t size) 934 ngx_unescape_uri(u_char **dst, u_char **src, size_t size, ngx_uint_t type)
935 { 935 {
936 u_char *d, *s, ch, c, decoded; 936 u_char *d, *s, ch, c, decoded;
937 enum { 937 enum {
938 sw_usual = 0, 938 sw_usual = 0,
939 sw_quoted, 939 sw_quoted,
950 950
951 ch = *s++; 951 ch = *s++;
952 952
953 switch (state) { 953 switch (state) {
954 case sw_usual: 954 case sw_usual:
955 if (ch == '?') { 955 if (ch == '?' && type == NGX_UNESCAPE_URI) {
956 *d++ = ch; 956 *d++ = ch;
957 goto done; 957 goto done;
958 } 958 }
959 959
960 if (ch == '%') { 960 if (ch == '%') {
993 state = sw_usual; 993 state = sw_usual;
994 994
995 if (ch >= '0' && ch <= '9') { 995 if (ch >= '0' && ch <= '9') {
996 ch = (u_char) ((decoded << 4) + ch - '0'); 996 ch = (u_char) ((decoded << 4) + ch - '0');
997 997
998 if (ch > '%' && ch < 0x7f) { 998 if (type == NGX_UNESCAPE_URI) {
999 *d++ = ch; 999 if (ch > '%' && ch < 0x7f) {
1000 *d++ = ch;
1001 break;
1002 }
1003
1004 *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
1005
1000 break; 1006 break;
1001 } 1007 }
1002 1008
1003 *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1); 1009 *d++ = ch;
1004 1010
1005 break; 1011 break;
1006 } 1012 }
1007 1013
1008 c = (u_char) (ch | 0x20); 1014 c = (u_char) (ch | 0x20);
1009 if (c >= 'a' && c <= 'f') { 1015 if (c >= 'a' && c <= 'f') {
1010 ch = (u_char) ((decoded << 4) + c - 'a' + 10); 1016 ch = (u_char) ((decoded << 4) + c - 'a' + 10);
1011 1017
1012 if (ch == '?') { 1018 if (type == NGX_UNESCAPE_URI) {
1013 *d++ = ch; 1019 if (ch == '?') {
1014 goto done; 1020 *d++ = ch;
1015 } 1021 goto done;
1016 1022 }
1017 if (ch > '%' && ch < 0x7f) { 1023
1018 *d++ = ch; 1024 if (ch > '%' && ch < 0x7f) {
1025 *d++ = ch;
1026 break;
1027 }
1028
1029 *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
1019 break; 1030 break;
1020 } 1031 }
1021 1032
1022 *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1); 1033 *d++ = ch;
1023 1034
1024 break; 1035 break;
1025 } 1036 }
1026 1037
1027 /* the invalid quoted character */ 1038 /* the invalid quoted character */