Skip to content

Commit

Permalink
more closely match default tar errors (GNU + BSD binaries)
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Dec 1, 2020
1 parent c528cc7 commit 20a6137
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ func (te *Extractor) Sanitize(toggle bool) {

// outputPath returns the path at which to place tarPath
func (te *Extractor) outputPath(tarPath string) (outPath string, err error) {
elems := strings.Split(tarPath, "/") // break into elems
elems := strings.Split(tarPath, "/") // break into elems
for _, e := range elems {
if e == ".." {
return "", fmt.Errorf("%s : path contains '..'", tarPath)
}
}
elems = elems[1:] // remove original root
outPath = strings.Join(elems, "/") // join elems
outPath = gopath.Join(te.Path, outPath) // rebase on to extraction target root
Expand Down

0 comments on commit 20a6137

Please sign in to comment.