diff --git a/private/pkg/storage/storagearchive/storagearchive.go b/private/pkg/storage/storagearchive/storagearchive.go index 3f78a2b1d5..0dbf58917d 100644 --- a/private/pkg/storage/storagearchive/storagearchive.go +++ b/private/pkg/storage/storagearchive/storagearchive.go @@ -22,6 +22,7 @@ import ( "fmt" "io" "math" + "strings" "github.com/bufbuild/buf/private/pkg/normalpath" "github.com/bufbuild/buf/private/pkg/storage" @@ -109,6 +110,19 @@ func Untar( if tarHeader.Size < 0 { return fmt.Errorf("invalid size for tar file %s: %d", tarHeader.Name, tarHeader.Size) } + if strings.HasPrefix(tarHeader.FileInfo().Name(), "._") { + // When creating tar archives using libarchive on macOS, extended + // attributes on files will be stored as an AppleDouble file with + // a prefix of "._". These entries must be omitted in processing. + // This concession is accepted under the following reasoning: + // 1. Filename is the only distinctive property of these entries. + // 2. Protobuf IDL files prefixed with ._ are extremely uncommon. + // 3. Multiple passes through the archive header are undesirable. + // If this proves to be too obtrusive, we can use multiple passes + // and possibly use PAXHeaders to precisely exclude only relevant + // attribute files without omitting all files prefixed with "._". + continue + } path, ok, err := unmapArchivePath(tarHeader.Name, mapper, stripComponentCount) if err != nil { return err