Skip to content

Commit ba0e497

Browse files
committed
Don't apply max_form_parts to non-multipart forms
This matches Flask's (Werkzeug's) behaviour. This is applicable as url encoded forms are quick to parse and the number of parts is therefore not something that needs restricting.
1 parent 2d36598 commit ba0e497

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

src/quart/formparser.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,10 @@ async def _parse_urlencoded(
113113
content_length: int | None,
114114
options: dict[str, str],
115115
) -> tuple[MultiDict, MultiDict]:
116-
try:
117-
form = parse_qsl(
118-
(await body).decode(),
119-
keep_blank_values=True,
120-
max_num_fields=self.max_form_parts,
121-
)
122-
except ValueError:
123-
raise RequestEntityTooLarge() from None
116+
form = parse_qsl(
117+
(await body).decode(),
118+
keep_blank_values=True,
119+
)
124120
return self.cls(form), self.cls()
125121

126122
parse_functions: dict[str, ParserFunc] = {

tests/test_formparser.py

-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pytest
44
from werkzeug.exceptions import RequestEntityTooLarge
55

6-
from quart.formparser import FormDataParser
76
from quart.formparser import MultiPartParser
87
from quart.wrappers.request import Body
98

@@ -20,12 +19,3 @@ async def test_multipart_max_form_memory_size() -> None:
2019

2120
with pytest.raises(RequestEntityTooLarge):
2221
await parser.parse(body, b"bound", 0)
23-
24-
25-
async def test_formparser_max_num_parts() -> None:
26-
parser = FormDataParser(max_form_parts=1)
27-
body = Body(None, None)
28-
body.set_result(b"param1=data1&param2=data2&param3=data3")
29-
30-
with pytest.raises(RequestEntityTooLarge):
31-
await parser.parse(body, "application/x-url-encoded", None)

0 commit comments

Comments
 (0)