From 01c5233b53d931996844716dfe80511fd1f9abb5 Mon Sep 17 00:00:00 2001 From: Flare Date: Sun, 18 Sep 2016 23:46:52 +0800 Subject: [PATCH] Fixed 404 caused by unexpected question mark This fixes 404 caused when creating new files or wiki pages with question marks. Amended to force CI rebuild --- modules/template/template.go | 2 +- routers/repo/editor.go | 2 +- templates/repo/wiki/view.tmpl | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/template/template.go b/modules/template/template.go index 3a6eb042bb..f005d5ce17 100644 --- a/modules/template/template.go +++ b/modules/template/template.go @@ -97,7 +97,7 @@ func NewFuncMap() []template.FuncMap { "MD5": base.EncodeMD5, "ActionContent2Commits": ActionContent2Commits, "EscapePound": func(str string) string { - return strings.NewReplacer("%", "%25", "#", "%23", " ", "%20").Replace(str) + return strings.NewReplacer("%", "%25", "#", "%23", " ", "%20", "?", "%3F").Replace(str) }, "RenderCommitMessage": RenderCommitMessage, "ThemeColorMetaTag": func() string { diff --git a/routers/repo/editor.go b/routers/repo/editor.go index 428a25d568..f572615e78 100644 --- a/routers/repo/editor.go +++ b/routers/repo/editor.go @@ -264,7 +264,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo return } - ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + form.TreePath) + ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + strings.NewReplacer("%", "%25", "#", "%23", " ", "%20", "?", "%3F").Replace(form.TreePath)) } func EditFilePost(ctx *context.Context, form auth.EditRepoFileForm) { diff --git a/templates/repo/wiki/view.tmpl b/templates/repo/wiki/view.tmpl index ff828789c8..ecf80c884f 100644 --- a/templates/repo/wiki/view.tmpl +++ b/templates/repo/wiki/view.tmpl @@ -48,9 +48,9 @@ {{.title}} {{if and .IsRepositoryWriter (not .Repository.IsMirror)}}
- {{.i18n.Tr "repo.wiki.edit_page_button"}} + {{.i18n.Tr "repo.wiki.edit_page_button"}} {{.i18n.Tr "repo.wiki.new_page_button"}} - {{.i18n.Tr "repo.wiki.delete_page_button"}} + {{.i18n.Tr "repo.wiki.delete_page_button"}}
{{end}}