网络浏览器网址(http / https)不哪些字符(如果有)可以结束?
据我所知,不使用控制字符,例如
\0
nil。\t
标签。\n
换行。是否有完整的此类字符列表?
答案 0 :(得分:2)
有三种情况可以结束URI:
使用路径组件(如果没有查询/片段)
http://example.com/
http://example.com/path
http://example.com/path/path
查询组件(如果没有片段)
http://example.com/?query
http://example.com/path?query
http://example.com/path/path?query
使用片段组件
http://example.com/#fragment
http://example.com/path#fragment
http://example.com/path/path#fragment
http://example.com/?query#fragment
http://example.com/path?query#fragment
http://example.com/path/path?query#fragment
URI standard对这三个组件(Path,Query,Fragment)的结尾没有任何限制,因此允许使用相同的字符出现在组件中的任何其他位置:
空间(从测试看起来似乎被剥离了)
URI最后可以有(多个)空格字符(在所有三种情况下),但它们必须是百分比编码的。无论在何处,都不允许空间编码。
http://example.com/path-ending-with-four-spaces-%20%20%20%20
如果用户代理尝试将用户输入转换为有效的URI(即,对所有不能出现在组件中的字符进行百分比编码),则可能会假定尾随空格不是URI的一部分剥掉它们。
制表符和换行符也一样。如果是百分比编码,它们可以是URI的一部分。