diff --git a/lib/builder/step/add_copy_step.go b/lib/builder/step/add_copy_step.go index a53c94c1..6157a026 100644 --- a/lib/builder/step/add_copy_step.go +++ b/lib/builder/step/add_copy_step.go @@ -64,6 +64,11 @@ func newAddCopyStep( directive Directive, args, chown, fromStage string, fromPaths []string, toPath string, commit bool) (*addCopyStep, error) { + toPath = strings.Trim(toPath, "\"'") + for i := range fromPaths { + fromPaths[i] = strings.Trim(fromPaths[i], "\"'") + } + if len(fromPaths) > 1 && !(strings.HasSuffix(toPath, "/") || toPath == "." || toPath == "..") { return nil, fmt.Errorf("copying multiple source files, target must be a directory ending in \"/\"") } diff --git a/lib/builder/step/add_copy_step_test.go b/lib/builder/step/add_copy_step_test.go index 8076ede1..e1513894 100644 --- a/lib/builder/step/add_copy_step_test.go +++ b/lib/builder/step/add_copy_step_test.go @@ -44,3 +44,13 @@ func TestContextDirs(t *testing.T) { require.Equal("stage", stage) require.Len(paths, 1) } + +func TestTrimmingPaths(t *testing.T) { + require := require.New(t) + + ac, err := newAddCopyStep(Copy, "", "", "", []string{"\"/from/path\""}, "\"/to/path\"", false) + require.NoError(err) + + require.Equal("/from/path", ac.fromPaths[0]) + require.Equal("/to/path", ac.toPath) +}