Windows: Honour escape directive fully

Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 912781841422363219e064a1df6df39dabf4cd81
Component: engine
This commit is contained in:
John Howard
2016-10-21 11:55:39 -07:00
parent 6c158febcb
commit adbaf3869a
4 changed files with 59 additions and 20 deletions

View File

@ -6884,6 +6884,42 @@ func (s *DockerSuite) TestBuildShellWindowsPowershell(c *check.C) {
}
}
// Verify that escape is being correctly applied to words when escape directive is not \.
// Tests WORKDIR, ADD
func (s *DockerSuite) TestBuildEscapeNotBackslashWordTest(c *check.C) {
testRequires(c, DaemonIsWindows)
name := "testbuildescapenotbackslashwordtesta"
_, out, err := buildImageWithOut(name,
`# escape= `+"`"+`
FROM `+minimalBaseImage()+`
WORKDIR c:\windows
RUN dir /w`,
true)
if err != nil {
c.Fatal(err)
}
if !strings.Contains(strings.ToLower(out), "[system32]") {
c.Fatalf("Line with '[windows]' not found in output %q", out)
}
name = "testbuildescapenotbackslashwordtestb"
_, out, err = buildImageWithOut(name,
`# escape= `+"`"+`
FROM `+minimalBaseImage()+`
SHELL ["powershell.exe"]
WORKDIR c:\foo
ADD Dockerfile c:\foo\
RUN dir Dockerfile`,
true)
if err != nil {
c.Fatal(err)
}
if !strings.Contains(strings.ToLower(out), "-a----") {
c.Fatalf("Line with '-a----' not found in output %q", out)
}
}
// #22868. Make sure shell-form CMD is marked as escaped in the config of the image
func (s *DockerSuite) TestBuildCmdShellArgsEscaped(c *check.C) {
testRequires(c, DaemonIsWindows)