File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1+ Made chunked encoding HTTP header check stricter.
Original file line number Diff line number Diff line change @@ -491,9 +491,10 @@ def parse_headers(
491491 # chunking
492492 te = headers .get (hdrs .TRANSFER_ENCODING )
493493 if te is not None :
494- te_lower = te .lower ()
495- if "chunked" in te_lower :
494+ if "chunked" == te .lower ():
496495 chunked = True
496+ else :
497+ raise BadHttpMessage ("Request has invalid `Transfer-Encoding`" )
497498
498499 if hdrs .CONTENT_LENGTH in headers :
499500 raise BadHttpMessage (
Original file line number Diff line number Diff line change @@ -304,6 +304,15 @@ def test_request_te_chunked_with_content_length(parser: Any) -> None:
304304 parser .feed_data (text )
305305
306306
307+ def test_request_te_chunked123 (parser : Any ) -> None :
308+ text = b"GET /test HTTP/1.1\r \n " b"transfer-encoding: chunked123\r \n \r \n "
309+ with pytest .raises (
310+ http_exceptions .BadHttpMessage ,
311+ match = "Request has invalid `Transfer-Encoding`" ,
312+ ):
313+ parser .feed_data (text )
314+
315+
307316def test_conn_upgrade (parser : Any ) -> None :
308317 text = (
309318 b"GET /test HTTP/1.1\r \n "
You can’t perform that action at this time.
0 commit comments