mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
refuse empty request-target in HTTP request
A single slash is valid, but nothing at all can be safely refused. Python stdlib explicitly tells us it will not perform validation. https://docs.python.org/3/library/urllib.parse.html#url-parsing-security There are *four* `request-target` forms in rfc9112, none of them can be empty.
This commit is contained in:
parent
79b9a52cc8
commit
9ca4f1fdfc
@ -426,6 +426,17 @@ class Request(Message):
|
|||||||
# URI
|
# URI
|
||||||
self.uri = bits[1]
|
self.uri = bits[1]
|
||||||
|
|
||||||
|
# Python stdlib explicitly tells us it will not perform validation.
|
||||||
|
# https://docs.python.org/3/library/urllib.parse.html#url-parsing-security
|
||||||
|
# There are *four* `request-target` forms in rfc9112, none of them can be empty:
|
||||||
|
# 1. origin-form, which starts with a slash
|
||||||
|
# 2. absolute-form, which starts with a non-empty scheme
|
||||||
|
# 3. authority-form, (for CONNECT) which contains a colon after the host
|
||||||
|
# 4. asterisk-form, which is an asterisk (`\x2A`)
|
||||||
|
# => manually reject one always invalid URI: empty
|
||||||
|
if len(self.uri) == 0:
|
||||||
|
raise InvalidRequestLine(bytes_to_str(line_bytes))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
parts = split_request_uri(self.uri)
|
parts = split_request_uri(self.uri)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user