From 54c820feb3f8a7c75d35769504de19a3fdcf04cc Mon Sep 17 00:00:00 2001 From: Jeff Brooks Date: Thu, 10 Oct 2019 10:41:22 -0500 Subject: [PATCH] Ensure header value is string before conducting regex search on it. --- gunicorn/http/wsgi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gunicorn/http/wsgi.py b/gunicorn/http/wsgi.py index 32e7a2ac..b786bc09 100644 --- a/gunicorn/http/wsgi.py +++ b/gunicorn/http/wsgi.py @@ -253,10 +253,12 @@ class Response(object): if HEADER_RE.search(name): raise InvalidHeaderName('%r' % name) + value = str(value) + if HEADER_VALUE_RE.search(value): raise InvalidHeader('%r' % value) - value = str(value).strip() + value = value.strip() lname = name.lower().strip() if lname == "content-length": self.response_length = int(value)