问题描述
a> spec将分号列为保留(sub-delim)字符: 保留= gen-delims / sub-delims
gen-delims =:///? /#/[/]/@
sub-delims =! /$/& /'/(/)
/*/+/ /=
;的保留目的是什么?的URI中的分号?对于这个问题,其他子分隔符的目的是什么(我只知道&,+和=的目的)?
换句话说,它是保留的,所以想要URL中的某个分隔列表的人可以安全地使用;
作为分隔符,即使零件包含;
,只要内容是百分号编码的。换句话说,您可以这样做:
foo; bar; baz%3bqux
并将其解释为三个部分: foo
, code>,
baz; qux
。如果分号不是保留字符,;
和%3b
将是等效的,因此URI将不正确解释为四个部分: foo
, bar
, baz
qux
。
The RFC 3986 URI: Generic Syntax spec lists a semicolon as a reserved (sub-delim) character:
reserved = gen-delims / sub-delims
gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
What is the reserved purpose of the ";" of the semicolon in URIs? For that matter, what is the purpose of the other sub-delims (I'm only aware of purposes for "&", "+", and "=")?
There is an explanation at the end of section 3.3.
In other words, it is reserved so that people who want a delimited list of something in the URL can safely use ;
as a delimiter even if the parts contain ;
, as long as the contents are percent-encoded. In other words, you can do this:
foo;bar;baz%3bqux
and interpret it as three parts: foo
, bar
, baz;qux
. If semi-colon were not a reserved character, the ;
and %3b
would be equivalent so the URI would be incorrectly interpreted as four parts: foo
, bar
, baz
, qux
.
这篇关于URL中保留的分号是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!