jazzband / django-debug-toolbar

A configurable set of panels that display various debug information about the current request/response.
https://django-debug-toolbar.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
8.07k stars 1.05k forks source link

Issue 1682 #1932

Closed bkdekoning closed 3 months ago

bkdekoning commented 3 months ago

Description

Added functionality where the toolbar inspects the loaded HTML content for a form that includes a file input but does not have the encoding type set to multipart/form-data, and warns the user if so.

Subclassed Python's HTML parser and added a function called check_invalid_file_form_configuration in panels/templates/panel.py. The function checks all forms for a file input type and, if it exists, checks if the form has encoding type multipart/form-data. If it does not, the error message is shown in the Templates panel by passing it to record_stats. It also amends the nav_subtitle property of the panel to notify the user that there is an issue with their template. Added three tests and checked that the test suite passes for all compatible versions of Django and Python through Tox.

Fixes #1682

Checklist: