Commit 1688e10b authored by Tres Seaver's avatar Tres Seaver Committed by GitHub

Merge pull request #20 from navytux/y/zeo-ipv6

zeo: Fix parsing URI with IPv6 address
parents 71fb5f10 a3b501ce
......@@ -8,6 +8,8 @@
- Add support for Python 3.6.
- Fix parsing of ``zeo://`` URI with IPv6 address.
2.2.2 (2017-05-05)
------------------
......
......@@ -102,3 +102,4 @@ Contributors
- Steve Piercy, 2016/07/21
- Todd Koym, 2016/07/21
- Jim Fulton, 2017/04/13
- Kirill Smelkov, 2017/10/17
......@@ -134,21 +134,19 @@ class ClientStorageURIResolver(Resolver):
# urlsplit doesnt understand zeo URLs so force to something that
# doesn't break
uri = uri.replace('zeo://', 'http://', 1)
(scheme, netloc, path, query, frag) = urlsplit(uri)
if netloc:
u = urlsplit(uri)
if u.netloc:
# TCP URL
if ':' in netloc:
host, port = netloc.split(':')
port = int(port)
else:
host = netloc
host = u.hostname
port = u.port
if port is None:
port = 9991
args = ((host, port),)
else:
# Unix domain socket URL
path = os.path.normpath(path)
path = os.path.normpath(u.path)
args = (path,)
kw = dict(parse_qsl(query))
kw = dict(parse_qsl(u.query))
kw, unused = self.interpret_kwargs(kw)
if 'demostorage' in kw:
kw.pop('demostorage')
......
......@@ -252,6 +252,20 @@ class TestClientStorageURIResolver(unittest.TestCase):
factory()
ClientStorage.assert_called_once_with(('localhost', 8080), debug=1)
@mock.patch('zodburi.resolvers.ClientStorage')
def test_call_ipv6_no_port(self, ClientStorage):
resolver = self._makeOne()
factory, dbkw = resolver('zeo://[::1]?debug=true')
factory()
ClientStorage.assert_called_once_with(('::1', 9991), debug=1)
@mock.patch('zodburi.resolvers.ClientStorage')
def test_call_ipv6(self, ClientStorage):
resolver = self._makeOne()
factory, dbkw = resolver('zeo://[::1]:9090?debug=true')
factory()
ClientStorage.assert_called_once_with(('::1', 9090), debug=1)
@mock.patch('zodburi.resolvers.ClientStorage')
def test_call_unix(self, ClientStorage):
resolver = self._makeOne()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment