是否允许包含空格的URL? [英] Is a URL allowed to contain a space?

查看:143
本文介绍了是否允许包含空格的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新新新新200新新新200新200新新200新200新新200新200新新200新200新新200新200新新200新新200新200新新200新新200新新200新新新200新新200新新200新新200新新200新新200新新新200新新200新新新200新新200新新新200新新200新新新200新新200新新200新新200新新200新新新新作新新200新新新新旗新新200新新旗200如果URL 必须被编码,是 + 只是一个常见的惯例,还是合法的替代方法?



特别是,有人可以指向一个RFC,表明具有空格的URL必须被编码?



动机的问题:在测试一个网站时,我注意到一些URL是用空格构建的。 Firefox似乎做了正确的事情,这让我很惊讶!但是我希望能够将开发人员指向一个RFC,以便他们感到需要修复这些URL。

解决方案

根据 RFC 1738


不安全:



由于一些原因,字符可能不安全。 空格
字符是不安全的,因为有重要的空格可能会消失,并且当URL被转录或
排版或受到文字处理程序的处理时,可能会引入
无关紧要的空格。 strong>
字符<>是不安全的,因为它们被用作
分隔符在自由文本中的URL;在某些系统中,引号()用于
分隔URL。字符是不安全的,并且
总是被编码,因为它在万维网和其他
系统中使用,以从可能
跟随它的片断/锚标识符中分隔一个URL。 是不安全的,因为它用于其他字符的
编码。其他字符不安全,因为
网关和其他传输代理有时被称为修改
这样的字符,这些字符是{}|\^
[],和`



所有不安全的字符必须始终在URL 对于
示例,字符必须在URL内编码,即使在通常不会处理机智的
系统中h片段或锚点
标识符,以便如果URL被复制到
使用它们的另一个系统中,则无需更改URL编码。



Is a URI (specifically an HTTP URL) allowed to contain one or more space characters? If a URL must be encoded, is + just a commonly followed convention, or a legitimate alternative?

In particular, can someone point to an RFC that indicates that a URL with a space must be encoded?

Motivation for question: While beta-testing a web site, I noted that some URLs were constructed with spaces in them. Firefox seemed to do the right thing, which surprised me! But I wanted to be able to point the developers to an RFC so that they would feel the need to fix those URLs.

解决方案

As per RFC 1738:

Unsafe:

Characters can be unsafe for a number of reasons. The space character is unsafe because significant spaces may disappear and insignificant spaces may be introduced when URLs are transcribed or typeset or subjected to the treatment of word-processing programs. The characters "<" and ">" are unsafe because they are used as the delimiters around URLs in free text; the quote mark (""") is used to delimit URLs in some systems. The character "#" is unsafe and should always be encoded because it is used in World Wide Web and in other systems to delimit a URL from a fragment/anchor identifier that might follow it. The character "%" is unsafe because it is used for encodings of other characters. Other characters are unsafe because gateways and other transport agents are known to sometimes modify such characters. These characters are "{", "}", "|", "\", "^", "~", "[", "]", and "`".

All unsafe characters must always be encoded within a URL. For example, the character "#" must be encoded within URLs even in systems that do not normally deal with fragment or anchor identifiers, so that if the URL is copied into another system that does use them, it will not be necessary to change the URL encoding.

这篇关于是否允许包含空格的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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