comparison src/http/modules/ngx_http_log_module.c @ 376:d13234035cad NGINX_0_6_32

nginx 0.6.32 *) Change: the "none" parameter in the "ssl_session_cache" directive; now this is default parameter. Thanks to Rob Mueller. *) Change: now the 0x00-0x1F, '"' and '\' characters are escaped as \xXX in an access_log. Thanks to Maxim Dounin. *) Change: now nginx allows several "Host" request header line. *) Feature: the "modified" flag in the "expires" directive. *) Feature: the $uid_got and $uid_set variables may be used at any request processing stage. *) Feature: the $hostname variable. Thanks to Andrei Nigmatulin. *) Feature: DESTDIR support. Thanks to Todd A. Fisher and Andras Voroskoi. *) Bugfix: if sub_filter and SSI were used together, then responses might were transferred incorrectly. *) Bugfix: large SSI inclusions might be truncated. *) Bugfix: the "proxy_pass" directive did not work with the HTTPS protocol; the bug had appeared in 0.6.9. *) Bugfix: worker processes might not catch reconfiguration and log rotation signals. *) Bugfix: nginx could not be built on latest Fedora 9 Linux. Thanks to Roxis. *) Bugfix: a segmentation fault might occur in worker process on Linux, if keepalive was enabled.
author Igor Sysoev <http://sysoev.ru>
date Mon, 07 Jul 2008 00:00:00 +0400
parents 05693816539c
children
comparison
equal deleted inserted replaced
375:52f3c9c7eff0 376:d13234035cad
86 ngx_http_log_op_t *op, ngx_str_t *value); 86 ngx_http_log_op_t *op, ngx_str_t *value);
87 static size_t ngx_http_log_variable_getlen(ngx_http_request_t *r, 87 static size_t ngx_http_log_variable_getlen(ngx_http_request_t *r,
88 uintptr_t data); 88 uintptr_t data);
89 static u_char *ngx_http_log_variable(ngx_http_request_t *r, u_char *buf, 89 static u_char *ngx_http_log_variable(ngx_http_request_t *r, u_char *buf,
90 ngx_http_log_op_t *op); 90 ngx_http_log_op_t *op);
91 static uintptr_t ngx_http_log_escape(u_char *dst, u_char *src, size_t size);
91 92
92 93
93 static void *ngx_http_log_create_main_conf(ngx_conf_t *cf); 94 static void *ngx_http_log_create_main_conf(ngx_conf_t *cf);
94 static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf); 95 static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf);
95 static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, 96 static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent,
476 477
477 478
478 static size_t 479 static size_t
479 ngx_http_log_variable_getlen(ngx_http_request_t *r, uintptr_t data) 480 ngx_http_log_variable_getlen(ngx_http_request_t *r, uintptr_t data)
480 { 481 {
482 uintptr_t len;
481 ngx_http_variable_value_t *value; 483 ngx_http_variable_value_t *value;
482 484
483 value = ngx_http_get_indexed_variable(r, data); 485 value = ngx_http_get_indexed_variable(r, data);
484 486
485 if (value == NULL || value->not_found) { 487 if (value == NULL || value->not_found) {
486 return 1; 488 return 1;
487 } 489 }
488 490
489 return value->len; 491 len = ngx_http_log_escape(NULL, value->data, value->len);
492
493 value->escape = len ? 1 : 0;
494
495 return value->len + len * 3;
490 } 496 }
491 497
492 498
493 static u_char * 499 static u_char *
494 ngx_http_log_variable(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op) 500 ngx_http_log_variable(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
500 if (value == NULL || value->not_found) { 506 if (value == NULL || value->not_found) {
501 *buf = '-'; 507 *buf = '-';
502 return buf + 1; 508 return buf + 1;
503 } 509 }
504 510
505 return ngx_cpymem(buf, value->data, value->len); 511 if (value->escape == 0) {
512 return ngx_cpymem(buf, value->data, value->len);
513
514 } else {
515 return (u_char *) ngx_http_log_escape(buf, value->data, value->len);
516 }
517 }
518
519
520 static uintptr_t
521 ngx_http_log_escape(u_char *dst, u_char *src, size_t size)
522 {
523 ngx_uint_t i, n;
524 static u_char hex[] = "0123456789ABCDEF";
525
526 static uint32_t escape[] = {
527 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
528
529 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
530 0x00000004, /* 0000 0000 0000 0000 0000 0000 0000 0100 */
531
532 /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
533 0x10000000, /* 0001 0000 0000 0000 0000 0000 0000 0000 */
534
535 /* ~}| {zyx wvut srqp onml kjih gfed cba` */
536 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
537
538 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
539 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
540 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
541 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
542 };
543
544
545 if (dst == NULL) {
546
547 /* find the number of the characters to be escaped */
548
549 n = 0;
550
551 for (i = 0; i < size; i++) {
552 if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
553 n++;
554 }
555 src++;
556 }
557
558 return (uintptr_t) n;
559 }
560
561 for (i = 0; i < size; i++) {
562 if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
563 *dst++ = '\\';
564 *dst++ = 'x';
565 *dst++ = hex[*src >> 4];
566 *dst++ = hex[*src & 0xf];
567 src++;
568
569 } else {
570 *dst++ = *src++;
571 }
572 }
573
574 return (uintptr_t) dst;
506 } 575 }
507 576
508 577
509 static void * 578 static void *
510 ngx_http_log_create_main_conf(ngx_conf_t *cf) 579 ngx_http_log_create_main_conf(ngx_conf_t *cf)