• Joe Tsai's avatar
    archive/tar: return better WriteHeader errors · 3d62000a
    Joe Tsai authored
    WriteHeader may fail to encode a header for any number of reasons,
    which can be frustrating for the user when trying to create a tar archive.
    As we validate the Header, we generate an informative error message
    intended for human consumption and return that if and only if no
    format can be selected.
    
    This allows WriteHeader to return informative errors like:
        tar: cannot encode header: invalid PAX record: "linkpath = \x00hello"
        tar: cannot encode header: invalid PAX record: "SCHILY.xattr.foo=bar = baz"
        tar: cannot encode header: Format specifies GNU; and only PAX supports Xattrs
        tar: cannot encode header: Format specifies GNU; and GNU cannot encode ModTime=1969-12-31 15:59:59.0000005 -0800 PST
        tar: cannot encode header: Format specifies GNU; and GNU supports sparse files only with TypeGNUSparse
        tar: cannot encode header: Format specifies USTAR; and USTAR cannot encode ModTime=292277026596-12-04 07:30:07 -0800 PST
        tar: cannot encode header: Format specifies USTAR; and USTAR does not support sparse files
        tar: cannot encode header: Format specifies PAX; and only GNU supports TypeGNUSparse
    
    Updates #18710
    
    Change-Id: I82a498d6f29d02c4e73bce47b768eb578da8499c
    Reviewed-on: https://go-review.googlesource.com/58310
    Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    3d62000a
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...