aboutsummaryrefslogtreecommitdiff
path: root/src/archive/tar/reader_test.go
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>2018-01-01 16:16:43 -0800
committerJoe Tsai <thebrokentoaster@gmail.com>2018-02-13 18:36:49 +0000
commite4bde0510465eecd4c8a8293418b1cbed1e0e623 (patch)
tree37a77a82777c266a7f4dd105c2671b1a75ff52de /src/archive/tar/reader_test.go
parent5158aab7d662e274aed870ae6bf9cf8ae0786f5b (diff)
downloadgo-e4bde0510465eecd4c8a8293418b1cbed1e0e623.tar.xz
archive/tar: automatically promote TypeRegA
Change Reader to promote TypeRegA to TypeReg in headers, unless their name have a trailing slash which is already promoted to TypeDir. This will allow client code to handle just TypeReg instead both TypeReg and TypeRegA. Change Writer to promote TypeRegA to TypeReg or TypeDir in the headers depending on whether the name has a trailing slash. This normalization is motivated by the specification (in pax(1)): 0 represents a regular file. For backwards-compatibility, a typeflag value of binary zero ( '\0' ) should be recognized as meaning a regular file when extracting files from the archive. Archives written with this version of the archive file format create regular files with a typeflag value of the ISO/IEC 646:1991 standard IRV '0'. Fixes #22768. Change-Id: I149ec55824580d446cdde5a0d7a0457ad7b03466 Reviewed-on: https://go-review.googlesource.com/85656 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/archive/tar/reader_test.go')
-rw-r--r--src/archive/tar/reader_test.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/archive/tar/reader_test.go b/src/archive/tar/reader_test.go
index a6832d33b1..0fc29eaab6 100644
--- a/src/archive/tar/reader_test.go
+++ b/src/archive/tar/reader_test.go
@@ -189,7 +189,7 @@ func TestReader(t *testing.T) {
Gid: 5000,
Size: 5,
ModTime: time.Unix(1244593104, 0),
- Typeflag: '\x00',
+ Typeflag: '0',
}, {
Name: "small2.txt",
Mode: 0444,
@@ -197,7 +197,7 @@ func TestReader(t *testing.T) {
Gid: 5000,
Size: 11,
ModTime: time.Unix(1244593104, 0),
- Typeflag: '\x00',
+ Typeflag: '0',
}},
}, {
file: "testdata/pax.tar",
@@ -534,9 +534,10 @@ func TestReader(t *testing.T) {
// a buggy pre-Go1.8 tar.Writer.
file: "testdata/invalid-go17.tar",
headers: []*Header{{
- Name: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/foo",
- Uid: 010000000,
- ModTime: time.Unix(0, 0),
+ Name: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/foo",
+ Uid: 010000000,
+ ModTime: time.Unix(0, 0),
+ Typeflag: '0',
}},
}, {
// USTAR archive with a regular entry with non-zero device numbers.