表单提交时编码的 GET 键方括号

Form GET key square brackets encoded upon form submission

当我提交表单时,我的方括号最终编码为 url,如下所示: http://example.com/myurl?key%5B%5D=something

我正在检查 nginx access.log 看看我是否能在其中看到任何奇怪的东西,但它也是为 http://example.com/myurl?key%5B%5D=something 记录的相同的单个请求(这让我觉得没有重写导致这个)。

还有什么可能导致这种情况?不能说我以前遇到过这种情况。

在 chrome 和 Edge 中进行了测试,结果相同。

What else could be causing this?

浏览器。

来自the HTML spec

If the byte is in the range 0x2A, 0x2D, 0x2E, 0x30 to 0x39, 0x41 to 0x5A, > 0x5F, 0x61 to 0x7A
Leave the byte as is.

[]U+005B : LEFT SQUARE BRACKETU+005D : RIGHT SQUARE BRACKET,因此它们不在该范围内。

Otherwise

  1. Let s be a string consisting of a U+0025 PERCENT SIGN character (%) followed by uppercase ASCII hex digits representing the hexadecimal value of the byte in question (zero-padded if necessary).
  2. Encode the string s as US-ASCII, so that it is now a byte string.
  3. Replace the byte in question in the name or value being processed by the bytes in s, preserving their relative order.

因此它们被 %5B%5D

取代