Mercurial > hg > nginx-vendor-current
comparison src/http/modules/ngx_http_charset_filter_module.c @ 320:95183808f549 NGINX_0_6_4
nginx 0.6.4
*) Security: the "msie_refresh" directive allowed XSS.
Thanks to Maxim Boguk.
*) Change: the "proxy_store" and "fastcgi_store" directives were
changed.
*) Feature: the "proxy_store_access" and "fastcgi_store_access"
directives.
*) Bugfix: nginx did not work on Solaris/sparc64 if it was built by Sun
Studio.
Thanks to Andrei Nigmatulin.
*) Workaround: for Sun Studio 12.
Thanks to Jiang Hong.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 17 Jul 2007 00:00:00 +0400 |
parents | 5bef04fc3fd5 |
children | 4276c2f1f434 |
comparison
equal
deleted
inserted
replaced
319:6ccd0af7f704 | 320:95183808f549 |
---|---|
185 static ngx_int_t | 185 static ngx_int_t |
186 ngx_http_charset_header_filter(ngx_http_request_t *r) | 186 ngx_http_charset_header_filter(ngx_http_request_t *r) |
187 { | 187 { |
188 u_char *ct; | 188 u_char *ct; |
189 ngx_int_t charset, source_charset; | 189 ngx_int_t charset, source_charset; |
190 ngx_str_t *mc, *from, *to; | 190 ngx_str_t *mc, *from, *to, s; |
191 ngx_uint_t n; | 191 ngx_uint_t n; |
192 ngx_http_charset_t *charsets; | 192 ngx_http_charset_t *charsets; |
193 ngx_http_charset_ctx_t *ctx; | 193 ngx_http_charset_ctx_t *ctx; |
194 ngx_http_variable_value_t *vv; | 194 ngx_http_variable_value_t *vv; |
195 ngx_http_charset_loc_conf_t *lcf, *mlcf; | 195 ngx_http_charset_loc_conf_t *lcf, *mlcf; |
254 | 254 |
255 if (vv == NULL || vv->not_found) { | 255 if (vv == NULL || vv->not_found) { |
256 return NGX_ERROR; | 256 return NGX_ERROR; |
257 } | 257 } |
258 | 258 |
259 charset = ngx_http_charset_get_charset(charsets, n, | 259 s.len = vv->len; |
260 (ngx_str_t *) vv); | 260 s.data = vv->data; |
261 | |
262 charset = ngx_http_charset_get_charset(charsets, n, &s); | |
261 } | 263 } |
262 } | 264 } |
263 | 265 |
264 } else { | 266 } else { |
265 ctx = ngx_http_get_module_ctx(r->main, ngx_http_charset_filter_module); | 267 ctx = ngx_http_get_module_ctx(r->main, ngx_http_charset_filter_module); |
301 | 303 |
302 if (vv == NULL || vv->not_found) { | 304 if (vv == NULL || vv->not_found) { |
303 return NGX_ERROR; | 305 return NGX_ERROR; |
304 } | 306 } |
305 | 307 |
306 source_charset = ngx_http_charset_get_charset(charsets, n, | 308 s.len = vv->len; |
307 (ngx_str_t *) vv); | 309 s.data = vv->data; |
310 | |
311 source_charset = ngx_http_charset_get_charset(charsets, n, &s); | |
308 } | 312 } |
309 | 313 |
310 if (charset != NGX_HTTP_NO_CHARSET) { | 314 if (charset != NGX_HTTP_NO_CHARSET) { |
311 return ngx_http_charset_set_charset(r, mcf->charsets.elts, charset, | 315 return ngx_http_charset_set_charset(r, mcf->charsets.elts, charset, |
312 source_charset); | 316 source_charset); |
371 | 375 |
372 static ngx_int_t | 376 static ngx_int_t |
373 ngx_http_charset_get_charset(ngx_http_charset_t *charsets, ngx_uint_t n, | 377 ngx_http_charset_get_charset(ngx_http_charset_t *charsets, ngx_uint_t n, |
374 ngx_str_t *charset) | 378 ngx_str_t *charset) |
375 { | 379 { |
376 size_t len; | |
377 ngx_uint_t i; | 380 ngx_uint_t i; |
378 | 381 |
379 len = charset->len & 0xffff; | |
380 | |
381 for (i = 0; i < n; i++) { | 382 for (i = 0; i < n; i++) { |
382 if (charsets[i].name.len != len) { | 383 if (charsets[i].name.len != charset->len) { |
383 continue; | 384 continue; |
384 } | 385 } |
385 | 386 |
386 if (ngx_strncasecmp(charsets[i].name.data, charset->data, len) == 0) { | 387 if (ngx_strncasecmp(charsets[i].name.data, charset->data, charset->len) |
388 == 0) | |
389 { | |
387 return i; | 390 return i; |
388 } | 391 } |
389 } | 392 } |
390 | 393 |
391 return NGX_HTTP_NO_CHARSET; | 394 return NGX_HTTP_NO_CHARSET; |