[Django] #31189: django.contrib.auth: Password field help text generates invalid html

17 views
Skip to first unread message

Django

unread,
Jan 20, 2020, 4:40:46 PM1/20/20
to django-...@googlegroups.com
#31189: django.contrib.auth: Password field help text generates invalid html
--------------------------------------------------+------------------------
Reporter: Marc Nieper-Wißkirchen | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------------+------------------------
The help text for the password field of, say, the UserCreationForm, is
generated here:
https://github.com/django/django/blob/master/django/contrib/auth/password_validation.py#L78
and is an html list. The form methods, `as_table' and `as_p', however,
wrap the help text into a span tag. In the resulting rendered HTML, there
will thus be a ul tag inside a span tag, which is invalid html.

To solve this problem, the span tag needs to be a div.

--
Ticket URL: <https://code.djangoproject.com/ticket/31189>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 21, 2020, 3:44:38 AM1/21/20
to django-...@googlegroups.com
#31189: django.contrib.auth: Password field help text generates invalid html
-------------------------------------+-------------------------------------
Reporter: Marc Nieper- | Owner: nobody
Wißkirchen |

Type: Bug | Status: new
Component: contrib.auth | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Marc Nieper-Wißkirchen:

Old description:

> The help text for the password field of, say, the UserCreationForm, is
> generated here:
> https://github.com/django/django/blob/master/django/contrib/auth/password_validation.py#L78
> and is an html list. The form methods, `as_table' and `as_p', however,
> wrap the help text into a span tag. In the resulting rendered HTML, there
> will thus be a ul tag inside a span tag, which is invalid html.
>
> To solve this problem, the span tag needs to be a div.

New description:

The help text for the password field of, say, the UserCreationForm, is
generated here:
https://github.com/django/django/blob/master/django/contrib/auth/password_validation.py#L78
and is an html list. The form methods, `as_table' and `as_p', however,
wrap the help text into a span tag. In the resulting rendered HTML, there
will thus be a ul tag inside a span tag, which is invalid html.

To solve this problem, the span tag needs at least to be a div. But then
there is the problem that `as_p' renders everything inside a paragraph,
which also cannot take an html list, only phrasing content.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/31189#comment:1>

Django

unread,
Jan 21, 2020, 6:22:20 AM1/21/20
to django-...@googlegroups.com
#31189: Password field help texts generates invalid html when using as_p() and
as_table() helpers.

-------------------------------------+-------------------------------------
Reporter: Marc Nieper- | Owner: nobody
Wißkirchen |
Type: | Status: closed
Cleanup/optimization |
Component: contrib.auth | Version: 3.0
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => closed
* type: Bug => Cleanup/optimization
* resolution: => wontfix


Comment:

It was fixed in admins' templates in
2d26b4637f0318736955b54b34f270fe9500f795, see #27207.

Forms in `django.contrib.auth.forms` are designed to render properly in
Django admin and I don't think that we should override helpers in admin
forms to generate valid HTML in all helpers `as_ul()`, `as_p()`, and
`as_table()`, moreover even overriding `help_text_html` won't help in
`as_p()`. There's no feasible solution. You can re-use templates from
`admin/templates/admin`, e.g.
`admin/templates/admin/includes/fieldset.html` if you don't want to write
you're own custom templates.

--
Ticket URL: <https://code.djangoproject.com/ticket/31189#comment:2>

Reply all
Reply to author
Forward
0 new messages