From e21ce73fba321bb0d547ae1ed92b43155a386354 Mon Sep 17 00:00:00 2001 From: yanghaichao12 Date: Tue, 7 May 2019 14:23:30 -0400 Subject: [PATCH] Refactor:move clean method to suitable place --- pkg/kubectl/cmd/cp/cp.go | 6 ------ pkg/kubectl/cmd/cp/cp_test.go | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/kubectl/cmd/cp/cp.go b/pkg/kubectl/cmd/cp/cp.go index 2679c6f7af1..02612e06717 100644 --- a/pkg/kubectl/cmd/cp/cp.go +++ b/pkg/kubectl/cmd/cp/cp.go @@ -413,12 +413,6 @@ func recursiveTar(srcBase, srcFile, destBase, destFile string, tw *tar.Writer) e return nil } -// clean prevents path traversals by stripping them out. -// This is adapted from https://golang.org/src/net/http/fs.go#L74 -func clean(fileName string) string { - return path.Clean(string(os.PathSeparator) + fileName) -} - func (o *CopyOptions) untarAll(reader io.Reader, destDir, prefix string) error { // TODO: use compression here? tarReader := tar.NewReader(reader) diff --git a/pkg/kubectl/cmd/cp/cp_test.go b/pkg/kubectl/cmd/cp/cp_test.go index c7d75573d0e..d648d826028 100644 --- a/pkg/kubectl/cmd/cp/cp_test.go +++ b/pkg/kubectl/cmd/cp/cp_test.go @@ -551,6 +551,12 @@ func TestBadTar(t *testing.T) { } } +// clean prevents path traversals by stripping them out. +// This is adapted from https://golang.org/src/net/http/fs.go#L74 +func clean(fileName string) string { + return path.Clean(string(os.PathSeparator) + fileName) +} + func TestClean(t *testing.T) { tests := []struct { input string