Skip to content

Commit

Permalink
Clarify difference between untar code
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Apr 5, 2022
1 parent 89dc3e9 commit da44ab1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
7 changes: 1 addition & 6 deletions pkg/archive/untar.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@ import (
"time"
)

// TODO(bradfitz): this was copied from x/build/cmd/buildlet/buildlet.go
// but there were some buildlet-specific bits in there, so the code is
// forked for now. Unfork and add some opts arguments here, so the
// buildlet can use this code somehow.

// Untar reads the gzip-compressed tar file from r and writes it into dir.
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Edited on 2019-10-11 to remove support for nested folders when un-taring
// AE: Edited on 2019-10-11 to remove support for nested folders when un-taring
// so that all files are placed in the same target directory
func Untar(r io.Reader, dir string, quiet bool) error {
return untar(r, dir, quiet)
Expand Down
23 changes: 4 additions & 19 deletions pkg/archive/untar_nested.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import (
"time"
)

// Untar reads the gzip-compressed tar file from r and writes it into dir.
// UntarNested reads the gzip-compressed tar file from r and writes it into dir.
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
func UntarNested(r io.Reader, dir string) error {
return untarNested(r, dir)
}
Expand Down Expand Up @@ -109,21 +112,3 @@ func untarNested(r io.Reader, dir string) (err error) {
}
return nil
}

// func validRelativeDir(dir string) bool {
// if strings.Contains(dir, `\`) || path.IsAbs(dir) {
// return false
// }
// dir = path.Clean(dir)
// if strings.HasPrefix(dir, "../") || strings.HasSuffix(dir, "/..") || dir == ".." {
// return false
// }
// return true
// }

// func validRelPath(p string) bool {
// if p == "" || strings.Contains(p, `\`) || strings.HasPrefix(p, "/") || strings.Contains(p, "../") {
// return false
// }
// return true
// }

0 comments on commit da44ab1

Please sign in to comment.