summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-07-21 09:49:05 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-07-21 09:49:05 -0400
commit156e3a94c49fa43a862d0e8de6683d9d96794447 (patch)
treee486f2c036e5be3fcc7e58fb72697104f9c6bd7e
parent55c148b59a058f3845345a45c7aa33371a96e971 (diff)
downloadchat-156e3a94c49fa43a862d0e8de6683d9d96794447.tar.gz
chat-156e3a94c49fa43a862d0e8de6683d9d96794447.tar.bz2
chat-156e3a94c49fa43a862d0e8de6683d9d96794447.zip
Use QueryUnescape function to convert to a human readable filename in email notifications
-rw-r--r--api/post.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/api/post.go b/api/post.go
index 1170d6a4f..65f2d5978 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)
}