routes/repo/issue: fix redirect with unexpected escape (#5443)

pull/5446/head
Unknwon 2018-09-30 13:55:40 -04:00
parent 0d66b1cc1c
commit a221b2807f
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
2 changed files with 6 additions and 1 deletions

View File

@ -138,6 +138,11 @@ func (c *Context) JSONSuccess(data interface{}) {
c.JSON(http.StatusOK, data)
}
// RawRedirect simply calls underlying Redirect method with no escape.
func (c *Context) RawRedirect(location string, status ...int) {
c.Context.Redirect(location, status...)
}
// Redirect responses redirection wtih given location and status.
// It escapes special characters in the location string.
func (c *Context) Redirect(location string, status ...int) {

View File

@ -901,7 +901,7 @@ func NewComment(c *context.Context, f form.CreateComment) {
typeName = "pulls"
}
if comment != nil {
c.Redirect(fmt.Sprintf("%s/%s/%d#%s", c.Repo.RepoLink, typeName, issue.Index, comment.HashTag()))
c.RawRedirect(fmt.Sprintf("%s/%s/%d#%s", c.Repo.RepoLink, typeName, issue.Index, comment.HashTag()))
} else {
c.Redirect(fmt.Sprintf("%s/%s/%d", c.Repo.RepoLink, typeName, issue.Index))
}