mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-45874: Handle empty query string correctly in urllib.parse.parse_qsl (#29716)
This commit is contained in:
parent
4325a766f5
commit
e6fe10d340
3 changed files with 7 additions and 3 deletions
|
@ -740,12 +740,13 @@ def parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
|
|||
# is less than max_num_fields. This prevents a memory exhaustion DOS
|
||||
# attack via post bodies with many fields.
|
||||
if max_num_fields is not None:
|
||||
num_fields = 1 + qs.count(separator)
|
||||
num_fields = 1 + qs.count(separator) if qs else 0
|
||||
if max_num_fields < num_fields:
|
||||
raise ValueError('Max number of fields exceeded')
|
||||
|
||||
r = []
|
||||
for name_value in qs.split(separator):
|
||||
query_args = qs.split(separator) if qs else []
|
||||
for name_value in query_args:
|
||||
if not name_value and not strict_parsing:
|
||||
continue
|
||||
nv = name_value.split('=', 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue