Fixes #10860: Handle empty port after port delimiter in httplib

Thanks, Shawn Ligocki!

3.x version will come as a separate patch.
This commit is contained in:
Łukasz Langa 2011-10-18 17:16:00 +02:00
parent 086f927f25
commit 7a15390f83
3 changed files with 31 additions and 2 deletions

View file

@ -715,7 +715,10 @@ class HTTPConnection:
try:
port = int(host[i+1:])
except ValueError:
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
if host[i+1:] == "": # http://foo.com:/ == http://foo.com/
port = self.default_port
else:
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
host = host[:i]
else:
port = self.default_port