Browse Source

Fixed 404 caused by unexpected question mark (#3668)

This fixes 404 caused when creating new files or wiki pages with question marks.
pull/3781/merge
LefsFlare 8 years ago committed by 无闻
parent
commit
39fdb0f9c4
  1. 2
      modules/template/template.go
  2. 2
      routers/repo/editor.go
  3. 4
      templates/repo/wiki/view.tmpl

2
modules/template/template.go

@ -97,7 +97,7 @@ func NewFuncMap() []template.FuncMap {
"MD5": base.EncodeMD5, "MD5": base.EncodeMD5,
"ActionContent2Commits": ActionContent2Commits, "ActionContent2Commits": ActionContent2Commits,
"EscapePound": func(str string) string { "EscapePound": func(str string) string {
return strings.NewReplacer("%", "%25", "#", "%23", " ", "%20").Replace(str) return strings.NewReplacer("%", "%25", "#", "%23", " ", "%20", "?", "%3F").Replace(str)
}, },
"RenderCommitMessage": RenderCommitMessage, "RenderCommitMessage": RenderCommitMessage,
"ThemeColorMetaTag": func() string { "ThemeColorMetaTag": func() string {

2
routers/repo/editor.go

@ -264,7 +264,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
return 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) { func EditFilePost(ctx *context.Context, form auth.EditRepoFileForm) {

4
templates/repo/wiki/view.tmpl

@ -48,9 +48,9 @@
{{.title}} {{.title}}
{{if and .IsRepositoryWriter (not .Repository.IsMirror)}} {{if and .IsRepositoryWriter (not .Repository.IsMirror)}}
<div class="ui right"> <div class="ui right">
<a class="ui small button" href="{{.RepoLink}}/wiki/{{.PageURL}}/_edit">{{.i18n.Tr "repo.wiki.edit_page_button"}}</a> <a class="ui small button" href="{{.RepoLink}}/wiki/{{EscapePound .PageURL}}/_edit">{{.i18n.Tr "repo.wiki.edit_page_button"}}</a>
<a class="ui green small button" href="{{.RepoLink}}/wiki/_new">{{.i18n.Tr "repo.wiki.new_page_button"}}</a> <a class="ui green small button" href="{{.RepoLink}}/wiki/_new">{{.i18n.Tr "repo.wiki.new_page_button"}}</a>
<a class="ui red small button delete-button" href="" data-url="{{.RepoLink}}/wiki/{{.PageURL}}/delete" data-id="{{.PageURL}}">{{.i18n.Tr "repo.wiki.delete_page_button"}}</a> <a class="ui red small button delete-button" href="" data-url="{{.RepoLink}}/wiki/{{EscapePound .PageURL}}/delete" data-id="{{EscapePound .PageURL}}">{{.i18n.Tr "repo.wiki.delete_page_button"}}</a>
</div> </div>
{{end}} {{end}}
<div class="ui sub header"> <div class="ui sub header">

Loading…
Cancel
Save