URL 片段或查询中是否允许使用斜杠? [英] Are slashes allowed in URL fragment or query?

查看:26
本文介绍了URL 片段或查询中是否允许使用斜杠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 URL 的一般形式的理解是它如下所示:

My understanding of the general form of a URL is that it looks as follows:

<scheme>://<host><path>?<query>#<fragment>

查询或片段中是否可以有任何正斜杠?更一般地说,是否有专门为 URL 的任何单个部分保留的字符?

Can there be any forward slashes in either the query or the fragment? More generally, are there any characters that are specifically reserved for any single part of a URL?

推荐答案

STD 66 定义了 片段 为:

fragment = *( pchar/"/"/"?" )

所以除了来自 pchar 集合的字符(unreserved/pct-encoded/sub-delims/":"/"@"),/? 可以直接在片段中使用(即不需要百分比编码).

So aside from characters from the pchar set (unreserved / pct-encoded / sub-delims / ":" / "@"), the / and the ? can be used in the fragment directly (i.e., percent-encoding is not needed).

/ 甚至在正文中明确提到:

The / is even mentioned explicitly in the text:

允许字符斜杠(/")和问号(?")表示片段标识符内的数据.请注意,当将此数据用作相对引用的基本 URI(第 5.1 节)时,一些较旧的错误实现可能无法正确处理此数据.

The characters slash ("/") and question mark ("?") are allowed to represent data within the fragment identifier. Beware that some older, erroneous implementations may not handle this data correctly when it is used as the base URI for relative references (Section 5.1).

这篇关于URL 片段或查询中是否允许使用斜杠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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