work around parse_qs behavior in python < 3.11

This commit is contained in:
Mike McLean 2025-02-24 10:40:11 -05:00
parent 8e55098458
commit af18c59623

View file

@ -211,6 +211,12 @@ class FieldStorageCompat(Mapping):
"""Emulate the parts of cgi.FieldStorage that we need"""
def __init__(self, environ):
qs = environ.get('QUERY_STRING', '')
if not qs:
# for python < 3.11, parse_qs will error on a blank string
self.data = {}
return
data = parse_qs(environ.get('QUERY_STRING', ''), strict_parsing=True,
keep_blank_values=True)
# replace singleton lists with single values