mirror of https://github.com/docker/docker-py.git
relax PORT_SPEC regex so it accept and ignore square brackets
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
55f405e04a
commit
563124163a
|
|
@ -3,7 +3,7 @@ import re
|
||||||
PORT_SPEC = re.compile(
|
PORT_SPEC = re.compile(
|
||||||
"^" # Match full string
|
"^" # Match full string
|
||||||
"(" # External part
|
"(" # External part
|
||||||
r"((?P<host>[a-fA-F\d.:]+):)?" # Address
|
r"(\[?(?P<host>[a-fA-F\d.:]+)\]?:)?" # Address
|
||||||
r"(?P<ext>[\d]*)(-(?P<ext_end>[\d]+))?:" # External range
|
r"(?P<ext>[\d]*)(-(?P<ext_end>[\d]+))?:" # External range
|
||||||
")?"
|
")?"
|
||||||
r"(?P<int>[\d]+)(-(?P<int_end>[\d]+))?" # Internal range
|
r"(?P<int>[\d]+)(-(?P<int_end>[\d]+))?" # Internal range
|
||||||
|
|
|
||||||
|
|
@ -541,6 +541,12 @@ class PortsTest(unittest.TestCase):
|
||||||
assert internal_port == ["2000"]
|
assert internal_port == ["2000"]
|
||||||
assert external_port == [("2001:abcd:ef00::2", "1000")]
|
assert external_port == [("2001:abcd:ef00::2", "1000")]
|
||||||
|
|
||||||
|
def test_split_port_with_ipv6_square_brackets_address(self):
|
||||||
|
internal_port, external_port = split_port(
|
||||||
|
"[2001:abcd:ef00::2]:1000:2000")
|
||||||
|
assert internal_port == ["2000"]
|
||||||
|
assert external_port == [("2001:abcd:ef00::2", "1000")]
|
||||||
|
|
||||||
def test_split_port_invalid(self):
|
def test_split_port_invalid(self):
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
split_port("0.0.0.0:1000:2000:tcp")
|
split_port("0.0.0.0:1000:2000:tcp")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue