add proper url encoding for filenames
Этот коммит содержится в:
@@ -103,7 +103,9 @@ func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
imageDataList = append(imageDataList, buf.Bytes())
|
imageDataList = append(imageDataList, buf.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUrl := "/" + channelId + "/" + c.Session.UserId + "/" + uid + "/" + url.QueryEscape(files[i].Filename)
|
encName := utils.UrlEncode(files[i].Filename)
|
||||||
|
|
||||||
|
fileUrl := "/" + channelId + "/" + c.Session.UserId + "/" + uid + "/" + encName
|
||||||
resStruct.Filenames = append(resStruct.Filenames, fileUrl)
|
resStruct.Filenames = append(resStruct.Filenames, fileUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,6 +266,7 @@ func asyncGetFile(path string, fileData chan []byte) {
|
|||||||
go func() {
|
go func() {
|
||||||
data, getErr := readFile(path)
|
data, getErr := readFile(path)
|
||||||
if getErr != nil {
|
if getErr != nil {
|
||||||
|
l4g.Error(getErr)
|
||||||
fileData <- nil
|
fileData <- nil
|
||||||
} else {
|
} else {
|
||||||
fileData <- data
|
fileData <- data
|
||||||
|
|||||||
19
utils/urlencode.go
Обычный файл
19
utils/urlencode.go
Обычный файл
@@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
||||||
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func UrlEncode(str string) string {
|
||||||
|
strs := strings.Split(str, " ")
|
||||||
|
|
||||||
|
for i, s := range strs {
|
||||||
|
strs[i] = url.QueryEscape(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(strs, "%20")
|
||||||
|
}
|
||||||
Ссылка в новой задаче
Block a user