• Caio Marcelo de Oliveira Filho's avatar
    archive/tar: automatically promote TypeRegA · e4bde051
    Caio Marcelo de Oliveira Filho authored
    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/85656Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
    Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    e4bde051
writer_test.go 36.6 KB