Skip to content

Commit

Permalink
Remove useless Content-Type detection that trips off ClamAV (gopasspw…
Browse files Browse the repository at this point in the history
…#1810)

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 gopasspw#1807

RELEASE_NOTES=[BUGFIX] Do not trigger ClamAV FP

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
  • Loading branch information
dominikschulz authored Feb 22, 2021
1 parent 4e37a0f commit 32cb4aa
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions internal/action/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 32cb4aa

Please sign in to comment.