Merge pull request #3258 from pajod/patch-empty-chunksize

gracefully handle chunked encoding missing size
This commit is contained in:
Benoit Chesneau 2024-08-06 13:20:52 +02:00 committed by GitHub
commit 7f559886cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 0 deletions

View File

@ -91,6 +91,8 @@ class ChunkedReader(object):
chunk_size = chunk_size.rstrip(b" \t")
if any(n not in b"0123456789abcdefABCDEF" for n in chunk_size):
raise InvalidChunkSize(chunk_size)
if len(chunk_size) == 0:
raise InvalidChunkSize(chunk_size)
chunk_size = int(chunk_size, 16)
if chunk_size == 0:

View File

@ -0,0 +1,7 @@
POST /chunked_no_chunk_size_but_ext HTTP/1.1\r\n
Transfer-Encoding: chunked\r\n
\r\n
;foo=bar\r\n
hello\r\n
0\r\n
\r\n

View File

@ -0,0 +1,2 @@
from gunicorn.http.errors import InvalidChunkSize
request = InvalidChunkSize

View File

@ -0,0 +1,7 @@
POST /chunked_no_chunk_size HTTP/1.1\r\n
Transfer-Encoding: chunked\r\n
\r\n
\r\n
hello\r\n
0\r\n
\r\n

View File

@ -0,0 +1,2 @@
from gunicorn.http.errors import InvalidChunkSize
request = InvalidChunkSize