开发者

What URL encoding irregularities do browsers generally tolerate?

开发者 https://www.devze.com 2023-02-21 21:08 出处:网络
Web browsers tend to do their best to recover malformed URLs. Let\'s start with a baseline google query.

Web browsers tend to do their best to recover malformed URLs.

Let's start with a baseline google query.

http://www.google.com/search?q=myq开发者_运维知识库uery

Which results in my browser (recent-ish build of Chrome) requesting.

GET http://www.google.com/search?q=myquery HTTP/1.1

Fully expected behavior obviously.

Let's try putting an unescaped space into the mix.

http://www.google.com/search?q=my query

GET http://www.google.com/search?q=my%20query HTTP/1.1

What if we use the % character? Because it's not followed by a valid character code the browser should escape it to %25

http://www.google.com/search?q=i always give 100%

GET http://www.google.com/search?q=i%20always%20give%20100% HTTP/1.1

Chrome didn't escape the %!

Is space substitution the only URL transformation an average browser will/is expected to perform? Are there libraries for performing these kinds of URL "salvaging" transformations?

0

精彩评论

暂无评论...
验证码 换一张
取 消