mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Refactor:move clean method to suitable place
This commit is contained in:
parent
a1588cfe34
commit
e21ce73fba
@ -413,12 +413,6 @@ func recursiveTar(srcBase, srcFile, destBase, destFile string, tw *tar.Writer) e
|
|||||||
return nil
|
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 {
|
func (o *CopyOptions) untarAll(reader io.Reader, destDir, prefix string) error {
|
||||||
// TODO: use compression here?
|
// TODO: use compression here?
|
||||||
tarReader := tar.NewReader(reader)
|
tarReader := tar.NewReader(reader)
|
||||||
|
@ -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) {
|
func TestClean(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input string
|
input string
|
||||||
|
Loading…
Reference in New Issue
Block a user