Closed
Description
Hi,
I think I found an issue in the web server included in CircuitPython. If you post a form back to the web server that has no input fields, OR contains only chekboxes and they all are clear (which causes no form data to be posted back), the web server seems to crash.
For example this form:
<form action="/update" method="post">
<input type="checkbox" name="test" value="1">
<input type="submit" value="Update">
</form>
When the checkbox is clear, and the form is posted back, when trying to access the field value (or any of the other relevant methods like get(...)):
@server.route("/update", POST)
def update(request: Request):
x = request.form_data.fields
The web server crashes with this error:
File "adafruit_httpserver/request.py", line 321, in form_data
File "adafruit_httpserver/request.py", line 144, in __init__
File "adafruit_httpserver/request.py", line 157, in _parse_x_www_form_urlencoded
ValueError: need more than 1 values to unpack
This is using adafruit_httpserver from adafruit-circuitpython-bundle-8.x-mpy-20230829.zip on a Rasberry PI Pico on Circuit Python 8.2.4
If I add a text or hidden input in the form for example, it works:
<form action="/update" method="post">
<input type="checkbox" name="test" value="1">
<input type="hidden" name="a" value="1">
<input type="submit" value="Update">
</form>
Metadata
Metadata
Assignees
Labels
No labels