URL中保留的分号是什么? [英] What is the semicolon reserved for in URLs?

查看:1637
本文介绍了URL中保留的分号是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RFC 3986 URI:通用语法

a> spec将分号列为保留(sub-delim)字符:

 保留= gen-delims / sub-delims 

gen-delims =:///? /#/[/]/@

sub-delims =! /$/& /'/(/)
/*/+/ /=

;的保留目的是什么?的URI中的分号?对于这个问题,其他子分隔符的目的是什么(我只知道&,+和=的目的)?


除了dot-段在
层次化路径中,路径段是
被通用的
语法视为不透明的。 URI生成应用程序
经常使用段中允许的保留字符
来定界
scheme-specific或
dereference-handler-specific
子组件。例如,
分号(;)和equals(=)
保留字符通常使用
分隔参数和参数
值适用于该段。
逗号(,)保留字符是
,通常用于类似目的。
例如,一个URI生产者可能
使用诸如name; v = 1.1
等段来表示对name的版本1.1
的引用,
使用一个段,如name,1.1到
表示相同。参数类型
可以由特定于方案的
语义定义,但在大多数情况下,参数的
语法特定于
实现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.

Aside from dot-segments in hierarchical paths, a path segment is considered opaque by the generic syntax. URI producing applications often use the reserved characters allowed in a segment to delimit scheme-specific or dereference-handler-specific subcomponents. For example, the semicolon (";") and equals ("=") reserved characters are often used to delimit parameters and parameter values applicable to that segment. The comma (",") reserved character is often used for similar purposes. For example, one URI producer might use a segment such as "name;v=1.1" to indicate a reference to version 1.1 of "name", whereas another might use a segment such as "name,1.1" to indicate the same. Parameter types may be defined by scheme-specific semantics, but in most cases the syntax of a parameter is specific to the implementation of the URI's dereferencing algorithm.

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 %3bwould be equivalent so the URI would be incorrectly interpreted as four parts: foo, bar, baz, qux.

这篇关于URL中保留的分号是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆