]> Cypherpunks repositories - gostls13.git/commit
archive/tar: automatically promote TypeRegA
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tue, 2 Jan 2018 00:16:43 +0000 (16:16 -0800)
committerJoe Tsai <thebrokentoaster@gmail.com>
Tue, 13 Feb 2018 18:36:49 +0000 (18:36 +0000)
commite4bde0510465eecd4c8a8293418b1cbed1e0e623
tree37a77a82777c266a7f4dd105c2671b1a75ff52de
parent5158aab7d662e274aed870ae6bf9cf8ae0786f5b
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>
src/archive/tar/common.go
src/archive/tar/reader.go
src/archive/tar/reader_test.go
src/archive/tar/tar_test.go
src/archive/tar/testdata/file-and-dir.tar [new file with mode: 0644]
src/archive/tar/testdata/trailing-slash.tar
src/archive/tar/writer.go
src/archive/tar/writer_test.go