URL / Link中的合法和非法字符是什么? [英] What are the legal and illegal characters in URL/Link?

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

问题描述

如果有非法字符会怎样? URL是否通过将非法字符编码为其他内容来自行修复?

What happens if there is a illegal character? Does the URL fix it self by encoding the illegal characters into something else?

推荐答案

允许的字符



RFC 3986 定义哪些URI组件允许使用哪些字符。

Allowed characters

RFC 3986 defines which characters are allowed in which URI components.

特定 URI方案的RFC可能进一步限制这一点。

RFCs for specific URI schemes might further restrict this.

如果您对HTTP / HTTPS URI感兴趣:它们在 RFC 7230 。 AFAIK他们对允许的字符没有进一步的限制,所以你可以坚持RFC 3986中的定义。

If you are interested in HTTP/HTTPS URIs: they are defined in RFC 7230. AFAIK they don’t have further restrictions regarding allowed characters, so you could stick to the definitions in RFC 3986.

取决于很多因素......可能是没有任何反应到不再工作。

Depends on many factors … could be anything from "nothing happens" to "doesn’t work anymore".


URL是否通过将非法字符编码为其他内容来自行修复?

Does the URL fix it self by encoding the illegal characters into something else?

URI无法自行修复,它只是一个字符串。

A URI can’t fix itself, it’s just a string.

使用此URI的客户端(浏览器,服务器,电子邮件客户端等)可能尝试修复URI (或使用无效的URI)根据自己的规则。

Clients working with this URI (browser, server, email client, etc.) may try to fix a URI (or work with invalid URIs) according to their own rules.

另请注意,URI与链接(或存储等)之间存在差异。)文档中的这个URI。

宿主语言(例如,HTML)可能有规则要编码的内容。这更改URI,只更改URI在本文档中的存储/指定方式。

Also note that there’s a difference between a URI and linking to (or storing etc.) this URI in a document.
The host language (e.g., HTML) might have rules what to encode. This does not change the URI, only the way the URI is stored/specified in this document.

例如,有效的URI http://example.com/a&b 必须在HTML文档中这样链接:

For example, the valid URI http://example.com/a&b would have to be linked like this in HTML documents:

<a href="http://example.com/a&amp;b">Link</a>

但是URI仍然是 http://example.com/a& b ,而非 http://example.com/a&amp;b

But the URI is still http://example.com/a&b, not http://example.com/a&amp;b.

这篇关于URL / Link中的合法和非法字符是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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