From 1f20ae593836da35cc49fde27f62ee3729ecf9a3 Mon Sep 17 00:00:00 2001 From: Dominik Schulz Date: Mon, 22 Feb 2021 22:04:53 +0100 Subject: [PATCH] Remove useless Content-Type detection that trips off ClamAV This header was a left over artifact from the MIME imeplementation and isn't really used anyway. So instead of fighting with ClamAV just remove it. Fixes #1807 RELEASE_NOTES=[BUGFIX] Do not trigger ClamAV FP Signed-off-by: Dominik Schulz --- internal/action/binary.go | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/internal/action/binary.go b/internal/action/binary.go index 887d0a01fb..f2820e63f9 100644 --- a/internal/action/binary.go +++ b/internal/action/binary.go @@ -7,10 +7,8 @@ import ( "encoding/base64" "fmt" "io" - "net/http" "os" "path/filepath" - "strings" "github.com/gopasspw/gopass/internal/out" "github.com/gopasspw/gopass/pkg/ctxutil" @@ -66,25 +64,16 @@ func (s *Action) Cat(c *cli.Context) error { } func secFromBytes(dst, src string, in []byte) gopass.Secret { - ct := http.DetectContentType(in) - - debug.Log("Read %d bytes of %s from %s to %s", len(in), ct, src, dst) + debug.Log("Read %d bytes from %s to %s", len(in), src, dst) sec := secrets.NewKV() - if err := sec.Set("Content-Type", ct); err != nil { - debug.Log("Failed to set Content-Type %q: %q", ct, err) - } if err := sec.Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filepath.Base(src))); err != nil { debug.Log("Failed to set Content-Disposition: %q", err) } - if strings.HasPrefix(ct, "text/") { - sec.Write(in) - } else { - sec.Write([]byte(base64.StdEncoding.EncodeToString(in))) - if err := sec.Set("Content-Transfer-Encoding", "Base64"); err != nil { - debug.Log("Failed to set Content-Transfer-Encoding: %q", err) - } + sec.Write([]byte(base64.StdEncoding.EncodeToString(in))) + if err := sec.Set("Content-Transfer-Encoding", "Base64"); err != nil { + debug.Log("Failed to set Content-Transfer-Encoding: %q", err) } return sec