必须在 URL 路径中同等对待“@”和“%40”吗?
Must '@' and '%40' be treated equivalently in URL paths?
跟进 Can I use an at symbol (@) inside URLs?
根据 top voted answer,@
不是 URL 路径中的保留字符(尽管它在主机中)。
但是,给定路径中的 @
,URL 编码形式是否可以互换?换句话说,twitter.com/@user
是否严格等同于 twitter.com/%40user
?
在实践中,它们似乎经常互换使用,但很好奇是否确实如此(例如 AbC@gmail.com
在技术上与 abc@gmail.com
不同,但几乎每个人都对它们一视同仁) .
更广泛地说,字符和 URL 编码版本何时需要相同对待,何时不同(例如 example.com/path%2Fasdf
与 example.com/path/asdf
不同)……
URI http://twitter.com/@user
和 http://twitter.com/%40user
不 等价。
URI 标准是 STD 66, which currently maps to RFC 3986 (which updates RFC 1738).
节 6.2.2.2. Percent-Encoding Normalization defines how to normalize percent-encoded URIs to compare them for equivalence (after uppercasing hexadecimal digits A
-F
, as defined by 6.2.2.1 Case Normalization).
它说:
[…] some URI producers percent-encode octets that do not require percent-encoding, resulting in URIs that are equivalent to their non-encoded counterparts. These URIs should be normalized by decoding any percent-encoded octet that corresponds to an unreserved character, as described in Section 2.3.
链接的第 2.3 节列出了未保留的字符,它们是:
- 阿尔法 (
a
-z
, A
-Z
)
- DIGIT (
0
-9
)
-
.
_
~
本节还指出,即使没有发生规范化:
URIs that differ in the replacement of an unreserved character with its corresponding percent-encoded US-ASCII octet are equivalent: they identify the same resource.
@
不是“未保留”集的一部分。它是 "reserved" set 的一部分,上面写着:
URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent.
跟进 Can I use an at symbol (@) inside URLs?
根据 top voted answer,@
不是 URL 路径中的保留字符(尽管它在主机中)。
但是,给定路径中的 @
,URL 编码形式是否可以互换?换句话说,twitter.com/@user
是否严格等同于 twitter.com/%40user
?
在实践中,它们似乎经常互换使用,但很好奇是否确实如此(例如 AbC@gmail.com
在技术上与 abc@gmail.com
不同,但几乎每个人都对它们一视同仁) .
更广泛地说,字符和 URL 编码版本何时需要相同对待,何时不同(例如 example.com/path%2Fasdf
与 example.com/path/asdf
不同)……
URI http://twitter.com/@user
和 http://twitter.com/%40user
不 等价。
URI 标准是 STD 66, which currently maps to RFC 3986 (which updates RFC 1738).
节 6.2.2.2. Percent-Encoding Normalization defines how to normalize percent-encoded URIs to compare them for equivalence (after uppercasing hexadecimal digits A
-F
, as defined by 6.2.2.1 Case Normalization).
它说:
[…] some URI producers percent-encode octets that do not require percent-encoding, resulting in URIs that are equivalent to their non-encoded counterparts. These URIs should be normalized by decoding any percent-encoded octet that corresponds to an unreserved character, as described in Section 2.3.
链接的第 2.3 节列出了未保留的字符,它们是:
- 阿尔法 (
a
-z
,A
-Z
) - DIGIT (
0
-9
) -
.
_
~
本节还指出,即使没有发生规范化:
URIs that differ in the replacement of an unreserved character with its corresponding percent-encoded US-ASCII octet are equivalent: they identify the same resource.
@
不是“未保留”集的一部分。它是 "reserved" set 的一部分,上面写着:
URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent.