From 5372cfd726273ce27a0c9ab363d90e33aa6f47ac Mon Sep 17 00:00:00 2001 From: "kayos@tcp.direct" Date: Wed, 16 Dec 2020 01:18:38 -0800 Subject: [PATCH] don't try to scrub gif exif data --- error.log | 17 ----------------- main.go | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 22 deletions(-) delete mode 100644 error.log diff --git a/error.log b/error.log deleted file mode 100644 index 9054407..0000000 --- a/error.log +++ /dev/null @@ -1,17 +0,0 @@ -2020/12/14 07:18:47 main.go:26: 127.0.0.1: 404 -2020/12/14 07:18:48 main.go:26: 127.0.0.1: 404 -2020/12/14 07:18:51 main.go:26: 127.0.0.1: 404 -2020/12/14 07:21:36 main.go:26: 127.0.0.1: error: value too large -2020/12/14 07:22:20 main.go:26: 127.0.0.1: error: value too large -2020/12/14 07:49:32 main.go:26: 127.0.0.1: http: no such file -2020/12/14 07:49:48 main.go:26: 127.0.0.1: http: no such file -2020/12/14 07:49:58 main.go:26: 127.0.0.1: http: no such file -2020/12/14 07:52:11 main.go:26: 127.0.0.1: 400 -2020/12/14 07:54:38 main.go:26: 127.0.0.1: 404 -2020/12/14 07:56:57 main.go:26: 127.0.0.1: 404 -2020/12/15 23:53:24 main.go:30: 127.0.0.1: 404 -2020/12/16 00:50:35 main.go:30: ::1: 400 -2020/12/16 00:50:49 main.go:30: ::1: 400 -2020/12/16 00:52:26 main.go:30: ::1: 400 -2020/12/16 00:55:58 main.go:31: 127.0.0.1: bad request -2020/12/16 00:56:00 main.go:31: 127.0.0.1: bad request diff --git a/main.go b/main.go index 7106240..ca6251e 100644 --- a/main.go +++ b/main.go @@ -62,6 +62,8 @@ func imgView(c *gin.Context) { func imgPost(c *gin.Context) { + var Scrubbed []byte + f, err := c.FormFile("upload") if err != nil { errThrow(c, http.StatusBadRequest, err.Error(), "no file detected within request") @@ -84,12 +86,18 @@ func imgPost(c *gin.Context) { fmt.Println("[imgPost] generating uid") uid := gouid.String(5) - fmt.Println("[imgPost][" + uid + "] dumping byte form of file and scrubbing exif") + fmt.Println("[imgPost][" + uid + "] dumping byte form of file") fbytes, err := ioutil.ReadAll(file) - Scrubbed, err := exifremove.Remove(fbytes) - if err != nil { - errThrow(c, http.StatusInternalServerError, err.Error(), "error scrubbing exif") - return + if imageFormat != "gif" { + fmt.Println("[imgPost][" + uid + "] scrubbing exif") + Scrubbed, err = exifremove.Remove(fbytes) + if err != nil { + errThrow(c, http.StatusInternalServerError, err.Error(), "error scrubbing exif") + return + } + } else { + fmt.Println("[imgPost][" + uid + "] skipping exif scrub for gif image") + Scrubbed = fbytes } fmt.Println("[imgPost][" + uid + "] calculating MD5 hash")