diff options
author | appilon <apilon@hashicorp.com> | 2019-02-27 16:43:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-27 16:43:31 -0500 |
commit | 844b5a68d8af4791755b8f0ad293cc99f5959183 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/hashicorp/go-getter/decompress.go | |
parent | 303b299eeb6b06e939e35905e4b34cb410dd9dc3 (diff) | |
parent | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (diff) | |
download | terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.tar.gz terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.tar.zst terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.zip |
Merge pull request #27 from terraform-providers/go-modules-2019-02-22
[MODULES] Switch to Go Modules
Diffstat (limited to 'vendor/github.com/hashicorp/go-getter/decompress.go')
-rw-r--r-- | vendor/github.com/hashicorp/go-getter/decompress.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/go-getter/decompress.go b/vendor/github.com/hashicorp/go-getter/decompress.go index d18174c..198bb0e 100644 --- a/vendor/github.com/hashicorp/go-getter/decompress.go +++ b/vendor/github.com/hashicorp/go-getter/decompress.go | |||
@@ -1,7 +1,15 @@ | |||
1 | package getter | 1 | package getter |
2 | 2 | ||
3 | import ( | ||
4 | "strings" | ||
5 | ) | ||
6 | |||
3 | // Decompressor defines the interface that must be implemented to add | 7 | // Decompressor defines the interface that must be implemented to add |
4 | // support for decompressing a type. | 8 | // support for decompressing a type. |
9 | // | ||
10 | // Important: if you're implementing a decompressor, please use the | ||
11 | // containsDotDot helper in this file to ensure that files can't be | ||
12 | // decompressed outside of the specified directory. | ||
5 | type Decompressor interface { | 13 | type Decompressor interface { |
6 | // Decompress should decompress src to dst. dir specifies whether dst | 14 | // Decompress should decompress src to dst. dir specifies whether dst |
7 | // is a directory or single file. src is guaranteed to be a single file | 15 | // is a directory or single file. src is guaranteed to be a single file |
@@ -16,14 +24,35 @@ var Decompressors map[string]Decompressor | |||
16 | func init() { | 24 | func init() { |
17 | tbzDecompressor := new(TarBzip2Decompressor) | 25 | tbzDecompressor := new(TarBzip2Decompressor) |
18 | tgzDecompressor := new(TarGzipDecompressor) | 26 | tgzDecompressor := new(TarGzipDecompressor) |
27 | txzDecompressor := new(TarXzDecompressor) | ||
19 | 28 | ||
20 | Decompressors = map[string]Decompressor{ | 29 | Decompressors = map[string]Decompressor{ |
21 | "bz2": new(Bzip2Decompressor), | 30 | "bz2": new(Bzip2Decompressor), |
22 | "gz": new(GzipDecompressor), | 31 | "gz": new(GzipDecompressor), |
32 | "xz": new(XzDecompressor), | ||
23 | "tar.bz2": tbzDecompressor, | 33 | "tar.bz2": tbzDecompressor, |
24 | "tar.gz": tgzDecompressor, | 34 | "tar.gz": tgzDecompressor, |
35 | "tar.xz": txzDecompressor, | ||
25 | "tbz2": tbzDecompressor, | 36 | "tbz2": tbzDecompressor, |
26 | "tgz": tgzDecompressor, | 37 | "tgz": tgzDecompressor, |
38 | "txz": txzDecompressor, | ||
27 | "zip": new(ZipDecompressor), | 39 | "zip": new(ZipDecompressor), |
28 | } | 40 | } |
29 | } | 41 | } |
42 | |||
43 | // containsDotDot checks if the filepath value v contains a ".." entry. | ||
44 | // This will check filepath components by splitting along / or \. This | ||
45 | // function is copied directly from the Go net/http implementation. | ||
46 | func containsDotDot(v string) bool { | ||
47 | if !strings.Contains(v, "..") { | ||
48 | return false | ||
49 | } | ||
50 | for _, ent := range strings.FieldsFunc(v, isSlashRune) { | ||
51 | if ent == ".." { | ||
52 | return true | ||
53 | } | ||
54 | } | ||
55 | return false | ||
56 | } | ||
57 | |||
58 | func isSlashRune(r rune) bool { return r == '/' || r == '\\' } | ||