From 156e3a94c49fa43a862d0e8de6683d9d96794447 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Tue, 21 Jul 2015 09:49:05 -0400 Subject: [PATCH] Use QueryUnescape function to convert to a human readable filename in email notifications --- api/post.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/post.go b/api/post.go index 1170d6a4f6..65f2d59780 100644 --- a/api/post.go +++ b/api/post.go @@ -11,6 +11,7 @@ import ( "github.com/mattermost/platform/store" "github.com/mattermost/platform/utils" "net/http" + "net/url" "path/filepath" "strconv" "strings" @@ -411,7 +412,12 @@ func fireAndForgetNotifications(post *model.Post, teamId, teamUrl string) { filenames := make([]string, len(post.Filenames)) onlyImages := true for i, filename := range post.Filenames { - filenames[i] = strings.Replace(filepath.Base(filename), "+", " ", -1) + var err error + if filenames[i], err = url.QueryUnescape(filepath.Base(filename)); err != nil { + // this should never error since filepath was escaped using url.QueryEscape + filenames[i] = filepath.Base(filename) + } + ext := filepath.Ext(filename) onlyImages = onlyImages && model.IsFileExtImage(ext) }