comparison src/core/ngx_string.c @ 126:df17fbafec8f NGINX_0_3_10

nginx 0.3.10 *) Change: the "valid_referers" directive and the "$invalid_referer" variable were moved to the new ngx_http_referer_module from the ngx_http_rewrite_module. *) Change: the "$apache_bytes_sent" variable name was changed to "$body_bytes_sent". *) Feature: the "$sent_http_..." variables. *) Feature: the "if" directive supports the "=" and "!=" operations. *) Feature: the "proxy_pass" directive supports the HTTPS protocol. *) Feature: the "proxy_set_body" directive. *) Feature: the "post_action" directive. *) Feature: the ngx_http_empty_gif_module. *) Feature: the "worker_cpu_affinity" directive for Linux. *) Bugfix: the "rewrite" directive did not unescape URI part in redirect, now it is unescaped except the %00-%25 and %7F-%FF characters. *) Bugfix: nginx could not be built by the icc 9.0 compiler. *) Bugfix: if the SSI was enabled for zero size static file, then the chunked response was encoded incorrectly.
author Igor Sysoev <http://sysoev.ru>
date Tue, 15 Nov 2005 00:00:00 +0300
parents d25a1d6034f1
children 91372f004adf
comparison
equal deleted inserted replaced
125:97504de1f89e 126:df17fbafec8f
926 } 926 }
927 } 927 }
928 928
929 return (uintptr_t) dst; 929 return (uintptr_t) dst;
930 } 930 }
931
932
933 void
934 ngx_unescape_uri(u_char **dst, u_char **src, size_t size)
935 {
936 u_char *d, *s, ch, c, decoded;
937 enum {
938 sw_usual = 0,
939 sw_quoted,
940 sw_quoted_second
941 } state;
942
943 d = *dst;
944 s = *src;
945
946 state = 0;
947 decoded = 0;
948
949 while (size--) {
950
951 ch = *s++;
952
953 switch (state) {
954 case sw_usual:
955 if (ch == '?') {
956 *d++ = ch;
957 goto done;
958 }
959
960 if (ch == '%') {
961 state = sw_quoted;
962 break;
963 }
964
965 *d++ = ch;
966 break;
967
968 case sw_quoted:
969
970 if (ch >= '0' && ch <= '9') {
971 decoded = (u_char) (ch - '0');
972 state = sw_quoted_second;
973 break;
974 }
975
976 c = (u_char) (ch | 0x20);
977 if (c >= 'a' && c <= 'f') {
978 decoded = (u_char) (c - 'a' + 10);
979 state = sw_quoted_second;
980 break;
981 }
982
983 /* skip the invalid quoted character */
984
985 s++;
986 size--;
987
988 break;
989
990 case sw_quoted_second:
991
992 if (ch >= '0' && ch <= '9') {
993 ch = (u_char) ((decoded << 4) + ch - '0');
994
995 state = sw_usual;
996
997 if (ch > '%' && ch < 0x7f) {
998 *d++ = ch;
999 break;
1000 }
1001
1002 *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
1003
1004 break;
1005 }
1006
1007 c = (u_char) (ch | 0x20);
1008 if (c >= 'a' && c <= 'f') {
1009 ch = (u_char) ((decoded << 4) + c - 'a' + 10);
1010
1011 if (ch == '?') {
1012 *d++ = ch;
1013 goto done;
1014 }
1015
1016 state = sw_usual;
1017
1018 if (ch > '%' && ch < 0x7f) {
1019 *d++ = ch;
1020 break;
1021 }
1022
1023 *d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
1024
1025 break;
1026 }
1027
1028 /* skip the invalid quoted character */
1029
1030 break;
1031 }
1032 }
1033
1034 done:
1035
1036 *dst = d;
1037 *src = s;
1038 }