Mercurial > hg > nginx
comparison src/core/ngx_string.c @ 452:23fb87bddda1 release-0.1.1
nginx-0.1.1-RELEASE import
*) Feature: the gzip_types directive.
*) Feature: the tcp_nodelay directive.
*) Feature: the send_lowat directive is working not only on OSes that
support kqueue NOTE_LOWAT, but also on OSes that support SO_SNDLOWAT.
*) Feature: the setproctitle() emulation for Linux and Solaris.
*) Bugfix: the "Location" header rewrite bug fixed while the proxying.
*) Bugfix: the ngx_http_chunked_module module may get caught in an
endless loop.
*) Bugfix: the /dev/poll module bugs fixed.
*) Bugfix: the responses were corrupted when the temporary files were
used while the proxying.
*) Bugfix: the unescaped requests were passed to the backend.
*) Bugfix: while the build configuration on Linux 2.4 the
--with-poll_module parameter was required.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 11 Oct 2004 15:07:03 +0000 |
parents | 42d11f017717 |
children | 295d97d70c69 |
comparison
equal
deleted
inserted
replaced
451:f40362e47689 | 452:23fb87bddda1 |
---|---|
126 | 126 |
127 *text = '\0'; | 127 *text = '\0'; |
128 } | 128 } |
129 | 129 |
130 | 130 |
131 void ngx_encode_base64(ngx_str_t *src, ngx_str_t *dst) | 131 void ngx_encode_base64(ngx_str_t *dst, ngx_str_t *src) |
132 { | 132 { |
133 u_char *d, *s; | 133 u_char *d, *s; |
134 size_t len; | 134 size_t len; |
135 static u_char basis64[] = | 135 static u_char basis64[] = |
136 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | 136 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
166 | 166 |
167 dst->len = d - dst->data; | 167 dst->len = d - dst->data; |
168 } | 168 } |
169 | 169 |
170 | 170 |
171 ngx_int_t ngx_decode_base64(ngx_str_t *src, ngx_str_t *dst) | 171 ngx_int_t ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src) |
172 { | 172 { |
173 size_t len; | 173 size_t len; |
174 u_char *d, *s; | 174 u_char *d, *s; |
175 static u_char basis64[] = | 175 static u_char basis64[] = |
176 { 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, | 176 { 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, |
229 | 229 |
230 return NGX_OK; | 230 return NGX_OK; |
231 } | 231 } |
232 | 232 |
233 | 233 |
234 #if 0 | 234 ngx_int_t ngx_escape_uri(u_char *dst, u_char *src, size_t size) |
235 char *ngx_psprintf(ngx_pool_t *p, const char *fmt, ...) | 235 { |
236 { | 236 ngx_int_t n; |
237 va_list args; | 237 ngx_uint_t i; |
238 | 238 static u_char hex[] = "0123456789abcdef"; |
239 va_start(args, fmt); | 239 static uint32_t escape[] = |
240 | 240 { 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
241 while (*fmt) { | 241 |
242 switch(*fmt++) { | 242 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */ |
243 case '%': | 243 0x80000021, /* 1000 0000 0000 0000 0000 0000 0010 0001 */ |
244 switch(*fmt++) { | 244 |
245 case 's': | 245 /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */ |
246 s = va_arg(args, char *); | 246 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */ |
247 n += ngx_strlen(s); | 247 |
248 break; | 248 /* ~}| {zyx wvut srqp onml kjih gfed cba` */ |
249 | 249 0x80000000, /* 1000 0000 0000 0000 0000 0000 0000 0000 */ |
250 default: | 250 |
251 n++; | 251 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
252 } | 252 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
253 default: | 253 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ |
254 n++; | 254 0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */ }; |
255 } | 255 |
256 } | 256 if (dst == NULL) { |
257 | 257 |
258 str = ngx_palloc(p, n); | 258 /* find the number of the characters to be escaped */ |
259 | 259 |
260 va_start(args, fmt); | 260 n = 0; |
261 | 261 |
262 for (i = 0; i < n; i++) { | 262 for (i = 0; i < size; i++) { |
263 switch(*fmt++) { | 263 if (escape[*src >> 5] & (1 << (*src & 0x1f))) { |
264 case '%': | 264 n++; |
265 switch(*fmt++) { | 265 } |
266 case 's': | 266 src++; |
267 s = va_arg(args, char *); | 267 } |
268 while (str[i++] = s); | 268 |
269 break; | 269 return n; |
270 | 270 } |
271 default: | 271 |
272 n++; | 272 for (i = 0; i < size; i++) { |
273 } | 273 if (escape[*src >> 5] & (1 << (*src & 0x1f))) { |
274 default: | 274 *dst++ = '%'; |
275 str[i] = *fmt; | 275 *dst++ = hex[*src >> 4]; |
276 } | 276 *dst++ = hex[*src & 0xf]; |
277 } | 277 src++; |
278 | 278 |
279 len += ngx_vsnprintf(errstr + len, sizeof(errstr) - len - 1, fmt, args); | 279 } else { |
280 | 280 *dst++ = *src++; |
281 va_end(args); | 281 } |
282 | 282 } |
283 } | 283 |
284 #endif | 284 return NGX_OK; |
285 } |