5 ms·
> But what the hell does it do??? In Safari and Firefox, I get an nginx 400 Bad Request page from en.wikipedia.org. But in Chrome, it seems to be redirecting to
by missblit 7y ago
> But what the hell does it do??? In Safari and Firefox, I get an nginx 400 Bad Request page from en.wikipedia.org. But in Chrome, it seems to be redirecting to a google search for the same url, when I type it into the address bar.
Firefox makes a GET request to "https://en.wikipedia.org/wiki/%00" https://en.wikipedia.org/wiki/%00", the server returns an HTTP/2 400 Bad Request. Presumably because the web-server considered the URL invalid.
Chrome decides the string isn't a valid URL up front. So it does what it normally does when you enter random junk in the address bar; it searches for it.
The dirty secret of URLs is that no one can quite agree on which ones are valid or how they should be canonicalized.
We can take WHATWG's spec as a modern way to handle URLs [1]. If I'm reading it right (50/50 chance!) the URL would be considered valid by that spec.
See also this article from the developer of curl: https://daniel.haxx.se/blog/2016/05/11/my-url-isnt-your-url/ https://daniel.haxx.se/blog/2016/05/11/my-url-isnt-your-url/
[1]
https://url.spec.whatwg.org/ https://url.spec.whatwg.org/
- kccqzy 7y ago> The dirty secret of URLs is that no one can quite agree on which ones are valid or how they should be canonicalized. Fun story. An engineer was working to migrate an old system from Python 2 to 3 before the Python 2 EOL deadline. The engineer decided to use the str type to represent URLs. Chaos ensued when suddenly non-UTF-8 URLs don't work any more. Turns out back when that system was designed, people were directly URL-encoding binary data into URLs.