#Form with only checkboxes (or empty) seems to crash web server

1 messages · Page 1 of 1 (latest)

bright light
#

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 cheboxes 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 trying to access the field value (or any of the other methods):

@server.route("/update", POST)
def update(request: Request):
    x = request.form_data.fields
 

Causes 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

Or am I perhaps missing something?

#

(this is using adafruit_httpserver)

#

If I add a text input in the form for example, it works.

bright light
#

(Also it seems that request.form_data.get(...) returns the **string ** "None" if a field doesn't exist, which is rather confusing)

lethal trench
bright light
#

I read through the description, but it doesn't seem to mention the above issue. I'll create a new one.

bright wedge
#

just post a <input type="hidden" value="anything">

#

or in your receive just set an arbitrary value before processing the form

#

also ur form fields should be within a container to meet a11y guidelines 🙂

#

e.g. <fieldset>