From b38fbd325da702825a7a0f457c0bb423d231523f Mon Sep 17 00:00:00 2001 From: Nate Berkopec Date: Fri, 4 Oct 2019 18:13:21 +0200 Subject: [PATCH] Strip header whitespace. Fix #1890. Code by @matthewd --- ext/puma_http11/puma_http11.c | 2 ++ test/test_http11.rb | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/puma_http11/puma_http11.c b/ext/puma_http11/puma_http11.c index 79e706d0f9..01df69e4b0 100644 --- a/ext/puma_http11/puma_http11.c +++ b/ext/puma_http11/puma_http11.c @@ -200,6 +200,8 @@ void http_field(puma_parser* hp, const char *field, size_t flen, f = rb_str_new(hp->buf, new_size); } + while (vlen > 0 && isspace(value[vlen - 1])) vlen--; + /* check for duplicate header */ v = rb_hash_aref(hp->request, f); diff --git a/test/test_http11.rb b/test/test_http11.rb index d7f8df6bda..be01404c75 100644 --- a/test/test_http11.rb +++ b/test/test_http11.rb @@ -199,9 +199,7 @@ def test_horrible_queries end end - # https://github.com/puma/puma/issues/1890 def test_trims_whitespace_from_headers - skip("Known failure, see issue 1890 on GitHub") parser = Puma::HttpParser.new req = {} http = "GET / HTTP/1.1\r\nX-Strip-Me: Strip This \r\n\r\n"