• Joe Tsai's avatar
    archive/tar: improve handling of directory paths · 4cd58c2f
    Joe Tsai authored
    The USTAR format says:
    <<<
    Implementors should be aware that the previous file format did not include
    a mechanism to archive directory type files.
    For this reason, the convention of using a filename ending with
    <slash> was adopted to specify a directory on the archive.
    >>>
    
    In light of this suggestion, make the following changes:
    * Writer.WriteHeader refuses to encode a header where a file that
    is obviously a file-type has a trailing slash in the name.
    * formatter.formatString avoids encoding a trailing slash in the event
    that the string is truncated (the full string will be encoded elsewhere,
    so stripping the slash is safe).
    * Reader.Next treats a TypeRegA (which is the zero value of Typeflag)
    as a TypeDir if the name has a trailing slash.
    
    Change-Id: Ibf27aa8234cce2032d92e5e5b28546c2f2ae5ef6
    Reviewed-on: https://go-review.googlesource.com/69293Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    4cd58c2f
Name
Last commit
Last update
..
gnu-incremental.tar Loading commit data...
gnu-long-nul.tar Loading commit data...
gnu-multi-hdrs.tar Loading commit data...
gnu-nil-sparse-data.tar Loading commit data...
gnu-nil-sparse-hole.tar Loading commit data...
gnu-not-utf8.tar Loading commit data...
gnu-sparse-big.tar Loading commit data...
gnu-utf8.tar Loading commit data...
gnu.tar Loading commit data...
hardlink.tar Loading commit data...
hdr-only.tar Loading commit data...
invalid-go17.tar Loading commit data...
issue10968.tar Loading commit data...
issue11169.tar Loading commit data...
issue12435.tar Loading commit data...
neg-size.tar Loading commit data...
nil-uid.tar Loading commit data...
pax-bad-hdr-file.tar Loading commit data...
pax-bad-mtime-file.tar Loading commit data...
pax-global-records.tar Loading commit data...
pax-multi-hdrs.tar Loading commit data...
pax-nil-sparse-data.tar Loading commit data...
pax-nil-sparse-hole.tar Loading commit data...
pax-nul-path.tar Loading commit data...
pax-nul-xattrs.tar Loading commit data...
pax-path-hdr.tar Loading commit data...
pax-pos-size-file.tar Loading commit data...
pax-records.tar Loading commit data...
pax-sparse-big.tar Loading commit data...
pax.tar Loading commit data...
small.txt Loading commit data...
small2.txt Loading commit data...
sparse-formats.tar Loading commit data...
star.tar Loading commit data...
trailing-slash.tar Loading commit data...
ustar-file-devs.tar Loading commit data...
ustar-file-reg.tar Loading commit data...
ustar.tar Loading commit data...
v7.tar Loading commit data...
writer-big-long.tar Loading commit data...
writer-big.tar Loading commit data...
writer.tar Loading commit data...
xattrs.tar Loading commit data...