don't try to scrub gif exif data

This commit is contained in:
kayos@tcp.direct 2020-12-16 01:18:38 -08:00
bovenliggende 5c43ec2fc8
commit 5372cfd726
2 gewijzigde bestanden met toevoegingen van 13 en 22 verwijderingen

Bestand weergeven

@ -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

18
main.go
Bestand weergeven

@ -62,6 +62,8 @@ func imgView(c *gin.Context) {
func imgPost(c *gin.Context) { func imgPost(c *gin.Context) {
var Scrubbed []byte
f, err := c.FormFile("upload") f, err := c.FormFile("upload")
if err != nil { if err != nil {
errThrow(c, http.StatusBadRequest, err.Error(), "no file detected within request") 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") fmt.Println("[imgPost] generating uid")
uid := gouid.String(5) 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) fbytes, err := ioutil.ReadAll(file)
Scrubbed, err := exifremove.Remove(fbytes) if imageFormat != "gif" {
if err != nil { fmt.Println("[imgPost][" + uid + "] scrubbing exif")
errThrow(c, http.StatusInternalServerError, err.Error(), "error scrubbing exif") Scrubbed, err = exifremove.Remove(fbytes)
return 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") fmt.Println("[imgPost][" + uid + "] calculating MD5 hash")