Opened 4 years ago

Closed 4 years ago

#31361 closed Cleanup/optimization (fixed)

Fix admin invalid HTML5 empty action="" attribute.

Reported by: Jon Dufresne Owned by: Jon Dufresne
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The attribute action="" (empty string) on the <form> element is invalid HTML5. The spec says:

The action and formaction content attributes, if specified, must have a value that is a valid non-empty URL potentially surrounded by spaces.

Emphasis on non-empty. The action attribute is allowed to be omitted, in which case the current URL is used which is the same behavior as now.

The nu validator reports the message:

Error: Bad value for attribute action on element form: Must be non-empty.

In the admin, this can occur in two templates:

https://github.com/django/django/blob/3.0.4/django/contrib/admin/templates/admin/auth/user/change_password.html#L22
https://github.com/django/django/blob/3.0.4/django/contrib/admin/templates/admin/change_form.html#L36

Change History (4)

comment:2 by Mariusz Felisiak, 4 years ago

Owner: changed from nobody to Jon Dufresne
Status: newassigned
Summary: Fix admin invalid HTML5 empty action="" attributeFix admin invalid HTML5 empty action="" attribute.
Triage Stage: UnreviewedAccepted

Thanks.

Note: A form example in MDN Web docs still contains action="".

comment:3 by Mariusz Felisiak, 4 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 3857a08b:

Fixed #31361 -- Fixed invalid action="" in admin forms.

The attribute action="" (empty string) on the <form> element is invalid
HTML5. The spec (https://html.spec.whatwg.org/#attr-fs-action) says:

The action and formaction content attributes, if specified, must have
a value that is a valid non-empty URL potentially surrounded by
spaces.

Emphasis on non-empty. The action attribute is allowed to be omitted, in
which case the current URL is used which is the same behavior as now.

Note: See TracTickets for help on using tickets.
Back to Top