Is array syntax using square brackets in URL query strings valid?

后端 未结 6 950
遥遥无期
遥遥无期 2020-12-03 01:21

Is it actually safe/valid to use multidimensional array synthax in the URL query string?

http://example.com?abc[]=123&abc[]=456

It seem

6条回答
  •  不思量自难忘°
    2020-12-03 01:49

    David N. Jafferian's answer is fantastic. I just want to add a couple updates and practical notes:

    1. For many years, every browser has left square brackets in query strings unencoded when submitting the request to the server. (Source: https://bugzilla.mozilla.org/show_bug.cgi?id=1152455#c6). As such, I imagine a huge portion of the web has come to rely on this behavior, which makes it extremely unlikely to change.

    2. My reading of the WHATWG URL standard which, at least for web purposes, can be seen as superseding RFC 3986, is that it codifies this behavior of not encoding [ and ] in query strings. I believe the relevant portion is: https://url.spec.whatwg.org/#query-state, which makes no reference about percent-encoding those characters.

提交回复
热议问题