Skip to content

Commit 6d94a23

Browse files
authored
Merge pull request kubernetes#77542 from yanghaichao12/dev0507
Refactor:move clean method to suitable place
2 parents c948cc8 + e21ce73 commit 6d94a23

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pkg/kubectl/cmd/cp/cp.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,6 @@ func recursiveTar(srcBase, srcFile, destBase, destFile string, tw *tar.Writer) e
413413
return nil
414414
}
415415

416-
// clean prevents path traversals by stripping them out.
417-
// This is adapted from https://golang.org/src/net/http/fs.go#L74
418-
func clean(fileName string) string {
419-
return path.Clean(string(os.PathSeparator) + fileName)
420-
}
421-
422416
func (o *CopyOptions) untarAll(reader io.Reader, destDir, prefix string) error {
423417
// TODO: use compression here?
424418
tarReader := tar.NewReader(reader)

pkg/kubectl/cmd/cp/cp_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,12 @@ func TestBadTar(t *testing.T) {
551551
}
552552
}
553553

554+
// clean prevents path traversals by stripping them out.
555+
// This is adapted from https://golang.org/src/net/http/fs.go#L74
556+
func clean(fileName string) string {
557+
return path.Clean(string(os.PathSeparator) + fileName)
558+
}
559+
554560
func TestClean(t *testing.T) {
555561
tests := []struct {
556562
input string

0 commit comments

Comments
 (0)