summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorChristian Sattler <sattler.christian@gmail.com>2021-12-12 08:41:12 (GMT)
committerGitHub <noreply@github.com>2021-12-12 08:41:12 (GMT)
commite6fe10d34096a23be7d26271cf6aba429313b01d (patch)
tree09dbfe6bda0f9207031b376a6a384f7a2fe2d0ce /Lib/urllib
parent4325a766f5f603ef6dfb8c4d5798e5e73cb5efd5 (diff)
downloadcpython-e6fe10d34096a23be7d26271cf6aba429313b01d.zip
cpython-e6fe10d34096a23be7d26271cf6aba429313b01d.tar.gz
cpython-e6fe10d34096a23be7d26271cf6aba429313b01d.tar.bz2
bpo-45874: Handle empty query string correctly in urllib.parse.parse_qsl (#29716)
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/parse.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index bf16d0f..67ba308 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -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)