Skip to content

Consider whether to encode the [ and ] characters in date input name field #1674

@frankieroberto

Description

@frankieroberto

The Date input component uses [ and ] characters in the name attribute if the namePrefix param is used, in order to generate attributes like dateOfBirth[day] and dateOfBirth[month] so that Express (and potentially other servers) can group the inputs together.

(This behaviour can be overridden if needed by setting separate name attributes for each input item).

However @colinrotherham points out that these characters may cause issues in some contexts:

Due to RFC3986 I'm still not sure how many web servers and proxies allow or understand square brackets when not encoded (e.g. Chrome GET requests, Apache Commons HttpClient, Apache Tomcat, IBM webMethods, Nginx)

A host identified by an Internet Protocol literal address, version 6
[RFC3513] or later, is distinguished by enclosing the IP literal
within square brackets ("[" and "]"). This is the only place where
square bracket characters are allowed in the URI syntax.

The characters are only used in the query string part of the URL (if the form is a GET request) or encoded form data (if the form is a POST request) so this may not be an issue.

However, if it is an issue, we could encode [ as %5B for better compatibility.

See #1570 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions