Skip to content

[Form] Too strict validation of form field names (HTML4 instead of HTML5) #53977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ThomasLandauer opened this issue Feb 16, 2024 · 0 comments · May be fixed by #53981
Open

[Form] Too strict validation of form field names (HTML4 instead of HTML5) #53977

ThomasLandauer opened this issue Feb 16, 2024 · 0 comments · May be fixed by #53981

Comments

@ThomasLandauer
Copy link
Contributor

Symfony version(s) affected

7.0.3

Description

Related to #53976 (which is basically the same for id attributes)

The checks being performed on the names of form fields are still following the HTML4 specs.
However, they changed in HTML5 - the only forbidden names are now:

  • empty string
  • isindex
  • _charset_ (case-insensitive)

Source: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-name

So I suggest to adjust the check.

How to reproduce

Setup a form with:

public function getBlockPrefix(): string
{
    return '-foo';
}

Resulting error:

The name "-foo" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").

Possible Solution

The check is happening in FormConfigBuilder::isValidName()

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants