URL路径中是否必须对'@'和'%40'进行等效处理? [英] Must '@' and '%40' be treated equivalently in URL paths?
问题描述
基于投票率最高的答案,@
在URL路径中不是保留字符(尽管它是保留字符)在主机中.
Based on the top voted answer, the @
is not a reserved character in the URL path (although it is in the host).
但是,在路径中给定@
的情况下,URL编码形式可以互换吗?换句话说,twitter.com/@user
严格等于twitter.com/%40user
吗?
However, given an @
in the path, is the URL-encoded form interchangeable? In other words, is twitter.com/@user
strictly equivalent to twitter.com/%40user
?
实际上,它们似乎经常互换使用,但很好奇是否确实如此(例如,AbC@gmail.com
在技术上与abc@gmail.com
不同,但几乎每个人都将它们相同).
In practice it seems like they're often used interchangeably, but curious if that is strictly the case (e.g. AbC@gmail.com
is technically different from abc@gmail.com
, but nearly everyone treats them the same).
更广泛地讲,什么时候需要将字符和具有URL编码的版本相同,何时需要区别对待(例如example.com/path%2Fasdf
与example.com/path/asdf
不同)……
More broadly, when do characters and there URL-encoded version need to be treated the same, and when different (e.g. example.com/path%2Fasdf
is NOT the same as example.com/path/asdf
) …
推荐答案
http://twitter.com/@user
和http://twitter.com/%40user
的URI 不等同.
URI标准为 STD 66 ,该标准当前映射到 RFC 1738 ).
The URI standard is STD 66, which currently maps to RFC 3986 (which updates RFC 1738).
6.2.2.2部分.百分比编码规范化定义了如何对百分比编码的URI进行规范化以比较它们的等效性(在由F
大写之后). org/html/rfc3986#section-6.2.2.1"rel =" nofollow> 6.2.2.1案例规范化).
The section 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).
它说:
[…]一些URI生产者不需要百分比编码的百分比编码八位字节,导致URI等同于未编码的八位字节.如第2.3节.
链接的第2.3节列出了未保留的字符,它们是:
The linked section 2.3 lists the unreserved characters, which are:
- ALPHA(
a
-z
,A
-Z
) - DIGIT(
0
-9
) -
-
.
_
~
- ALPHA (
a
-z
,A
-Z
) - DIGIT (
0
-9
) -
.
_
~
本节还指出,即使未进行标准化:
This sections also states that, even in case no normalization happens:
在将未保留的字符替换为其相应的百分比编码的US-ASCII八位字节方面不同的URI是等效的:它们标识相同的资源.
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.
@
不属于未保留"集.它是保留"集的一部分,其中表示:
The @
is not part of the "unreserved" set. It’s part of the "reserved" set, where it says:
在保留字符替换为其相应的百分比编码的八位字节方面有所不同的URI不是等效的.
URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent.
这篇关于URL路径中是否必须对'@'和'%40'进行等效处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!