A funny commit message in the root cause (as stated in the linked post) commit:
> Push code review advice from @sigmavirus24
> Push code review advice from @sigmavirus24
The code already had `host = ri.netloc.split(':')[0]` before that.
The actual root issue is urlparse doesn't split the host, user, pass and port and trying to do it manually is very error prone:
urllib.parse.urlparse('http://example.com:@evil.com:8080/')
ParseResult(scheme='http', netloc='example.com:@evil.com:8080', path='/', params='', query='', fragment='')
Compare this with php: parse_url ('http://example.com:@evil.com:8080/')
[
"scheme" => "http",
"host" => "evil.com",
"port" => 8080,
"user" => "example.com",
"pass" => "",
"path" => "/",
]