From e16c3124ddeaeda4f14a739e47664575cad4aaf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 2 Mar 2021 14:58:16 +0100 Subject: [PATCH] Disallow binary files with `gist edit -a` --- pkg/cmd/gist/edit/edit.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/cmd/gist/edit/edit.go b/pkg/cmd/gist/edit/edit.go index 98a3d36cd..1310f1482 100644 --- a/pkg/cmd/gist/edit/edit.go +++ b/pkg/cmd/gist/edit/edit.go @@ -245,6 +245,14 @@ func updateGist(apiClient *api.Client, hostname string, gist *shared.Gist) error } func getFilesToAdd(file string) (map[string]*shared.GistFile, error) { + isBinary, err := shared.IsBinaryFile(file) + if err != nil { + return nil, fmt.Errorf("failed to read file %s: %w", file, err) + } + if isBinary { + return nil, fmt.Errorf("failed to upload %s: binary file not supported", file) + } + content, err := ioutil.ReadFile(file) if err != nil { return nil, fmt.Errorf("failed to read file %s: %w", file, err)