Skip to content

Commit

Permalink
Add escapePath for getUploadFileUrl().
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeguy committed Jul 12, 2022
1 parent f7243f8 commit de49a45
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion object/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package object
import (
"bytes"
"fmt"
"net/url"
"strings"

"github.com/casdoor/casdoor/conf"
Expand All @@ -42,8 +43,19 @@ func getProviderEndpoint(provider *Provider) string {
return endpoint
}

func escapePath(path string) string {
tokens := strings.Split(path, "/")
if len(tokens) > 0 {
tokens[len(tokens)-1] = url.QueryEscape(tokens[len(tokens)-1])
}

res := strings.Join(tokens, "/")
return res
}

func getUploadFileUrl(provider *Provider, fullFilePath string, hasTimestamp bool) (string, string) {
objectKey := util.UrlJoin(util.GetUrlPath(provider.Domain), fullFilePath)
escapedPath := escapePath(fullFilePath)
objectKey := util.UrlJoin(util.GetUrlPath(provider.Domain), escapedPath)

host := ""
if provider.Type != "Local File System" {
Expand Down

0 comments on commit de49a45

Please sign in to comment.