From 7db76737ca661f242f9345a2be9a317c79da7575 Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Wed, 13 Dec 2017 18:32:59 -0800 Subject: [PATCH] Fix URL-quoting for resource names containing spaces Signed-off-by: Joffrey F --- docker/api/client.py | 2 +- tests/integration/api_network_test.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/api/client.py b/docker/api/client.py index cbe74b91..01a83ea4 100644 --- a/docker/api/client.py +++ b/docker/api/client.py @@ -206,7 +206,7 @@ class APIClient( 'instead'.format(arg, type(arg)) ) - quote_f = partial(six.moves.urllib.parse.quote_plus, safe="/:") + quote_f = partial(six.moves.urllib.parse.quote, safe="/:") args = map(quote_f, args) if kwargs.get('versioned_api', True): diff --git a/tests/integration/api_network_test.py b/tests/integration/api_network_test.py index f4fefde5..10e09dd7 100644 --- a/tests/integration/api_network_test.py +++ b/tests/integration/api_network_test.py @@ -484,3 +484,10 @@ class TestNetworks(BaseAPIIntegrationTest): assert self.client.inspect_network(net_name_swarm, scope='swarm') with pytest.raises(docker.errors.NotFound): self.client.inspect_network(net_name_swarm, scope='local') + + @requires_api_version('1.21') + def test_create_remove_network_with_space_in_name(self): + net_id = self.client.create_network('test 01') + self.tmp_networks.append(net_id) + assert self.client.inspect_network('test 01') + assert self.client.remove_network('test 01') is None # does not raise