From b7ebaf6d2078cbf4de00d0782be8bc1b1de644bb Mon Sep 17 00:00:00 2001 From: Ethan Koenig Date: Tue, 28 Nov 2017 01:43:51 -0800 Subject: Various wiki bug fixes (#2996) * Update macaron * Various wiki bug fixes --- modules/context/context.go | 3 ++- modules/templates/helper.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/context/context.go b/modules/context/context.go index 2c9afb36e7..6fb0a2cde3 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -36,6 +36,7 @@ type Context struct { Session session.Store Link string // current request URL + EscapedLink string User *models.User IsSigned bool IsBasicAuth bool @@ -157,7 +158,7 @@ func Contexter() macaron.Handler { csrf: x, Flash: f, Session: sess, - Link: setting.AppSubURL + strings.TrimSuffix(c.Req.URL.Path, "/"), + Link: setting.AppSubURL + strings.TrimSuffix(c.Req.URL.EscapedPath(), "/"), Repo: &Repository{ PullRequest: &PullRequest{}, }, diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 7fd0ed35a3..2b9e593360 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -11,6 +11,7 @@ import ( "fmt" "html/template" "mime" + "net/url" "path/filepath" "runtime" "strings" @@ -105,6 +106,7 @@ func NewFuncMap() []template.FuncMap { "ShortSha": base.ShortSha, "MD5": base.EncodeMD5, "ActionContent2Commits": ActionContent2Commits, + "PathEscape": url.PathEscape, "EscapePound": func(str string) string { return strings.NewReplacer("%", "%25", "#", "%23", " ", "%20", "?", "%3F").Replace(str) }, -- cgit v1.2.3