From 84c008bc27510c63fb22d14c8559e05e12953418 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Fri, 4 Jun 2021 21:44:43 -0700 Subject: added exif removal from jpeg, png images --- outboxPost.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'outboxPost.go') diff --git a/outboxPost.go b/outboxPost.go index 5729b2d..ab8c451 100644 --- a/outboxPost.go +++ b/outboxPost.go @@ -10,6 +10,7 @@ import "io/ioutil" import "os" import "regexp" import "strings" +import "os/exec" func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { @@ -31,7 +32,7 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { } contentType, _ := GetFileContentType(f) - + if(!SupportedMIMEType(contentType)) { w.WriteHeader(http.StatusNotAcceptable) w.Write([]byte("file type not supported")) @@ -361,6 +362,18 @@ func ObjectFromForm(r *http.Request, db *sql.DB, obj ObjectBase) ObjectBase { tempFile.Write(fileBytes) + re := regexp.MustCompile(`image/(jpe?g|png|webp)`) + if re.MatchString(obj.Attachment[0].MediaType) { + fileLoc := strings.ReplaceAll(obj.Attachment[0].Href, Domain, "") + + cmd := exec.Command("exiv2", "rm", "." + fileLoc) + + err := cmd.Run() + + CheckError(err, "error with removing exif data from image") + + } + obj.Preview = CreatePreviewObject(obj.Attachment[0]) } -- cgit v1.2.3