From f1542276081aa91396495059638d3ea30d4e5a10 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 23 Mar 2016 04:12:22 +0000 Subject: [PATCH] Fix Docker core dumps when removing network with special characters (#21401). This fix tries to fix Docker core dumps when removing network with special characters. The issue is from the fact that when docker client tries to pass the command to API, the networkID is not escaped in case of special characters. This also means other commands (not just `docker network rm`) may face the same issue (e.g., `docker network connect`). This fix adds the URL path escape to properly handle it. In addition, an integration test for network create and delete is added to cover the cases in #21401. This fix fixes #21401. Signed-off-by: Yong Tang (cherry picked from commit f8dc5562d0a74792c46b9382181ddf97e5d7cdac) Signed-off-by: David Calavera --- integration-cli/docker_cli_network_unix_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/integration-cli/docker_cli_network_unix_test.go b/integration-cli/docker_cli_network_unix_test.go index 6675cf1d26..2ee2092c69 100644 --- a/integration-cli/docker_cli_network_unix_test.go +++ b/integration-cli/docker_cli_network_unix_test.go @@ -1452,3 +1452,16 @@ func (s *DockerSuite) TestDockerNetworkInternalMode(c *check.C) { _, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first") c.Assert(err, check.IsNil) } + +// Test for #21401 +func (s *DockerNetworkSuite) TestDockerNetworkCreateDeleteSpecialCharacters(c *check.C) { + dockerCmd(c, "network", "create", "test@#$") + assertNwIsAvailable(c, "test@#$") + dockerCmd(c, "network", "rm", "test@#$") + assertNwNotAvailable(c, "test@#$") + + dockerCmd(c, "network", "create", "kiwl$%^") + assertNwIsAvailable(c, "kiwl$%^") + dockerCmd(c, "network", "rm", "kiwl$%^") + assertNwNotAvailable(c, "kiwl$%^") +}