[PATCH] Parse: underscores_in_headers should apply to the first character as well

Piotr Sikora piotr at cloudflare.com
Thu Mar 20 01:56:10 UTC 2014


# HG changeset patch
# User Piotr Sikora <piotr at cloudflare.com>
# Date 1395280497 25200
#      Wed Mar 19 18:54:57 2014 -0700
# Node ID 51d996a6bc65c4ca3c6621e4ad18235e6aa26abe
# Parent  c15350f4071c0207cdffbc8bbb3f28e8e57f4d86
Parse: underscores_in_headers should apply to the first character as well.

Signed-off-by: Piotr Sikora <piotr at cloudflare.com>

diff -r c15350f4071c -r 51d996a6bc65 src/http/ngx_http_parse.c
--- a/src/http/ngx_http_parse.c	Wed Mar 19 19:30:09 2014 +0400
+++ b/src/http/ngx_http_parse.c	Wed Mar 19 18:54:57 2014 -0700
@@ -886,6 +886,19 @@ ngx_http_parse_header_line(ngx_http_requ
                     break;
                 }
 
+                if (ch == '_') {
+                    if (allow_underscores) {
+                        hash = ngx_hash(hash, ch);
+                        r->lowcase_header[0] = ch;
+                        i = 1;
+
+                    } else {
+                        r->invalid_header = 1;
+                    }
+
+                    break;
+                }
+
                 if (ch == '\0') {
                     return NGX_HTTP_PARSE_INVALID_HEADER;
                 }



More information about the nginx-devel mailing list