summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorDeyong Zhu <05zhujiahua@gmail.com>2018-01-08 23:17:24 +0800
committerLauris BH <lauris@nix.lv>2018-01-08 17:17:24 +0200
commitd663cef2a578f0ec4ed034299d814558838a1172 (patch)
treedc8bd65ddc46652335037fceb925c1857a151a9b /routers
parentf48680888c14ad3dfe9cadb8efa4c8221731b71e (diff)
downloadgitea-d663cef2a578f0ec4ed034299d814558838a1172.tar.gz
gitea-d663cef2a578f0ec4ed034299d814558838a1172.zip
Fix branch name escaping in compare url (#3311)
* Fixes #3303
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/pull.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 515b6a91f8..35b5b0be2b 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -10,6 +10,7 @@ import (
"container/list"
"fmt"
"io"
+ "net/url"
"path"
"strings"
@@ -569,7 +570,19 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *
// format: <base branch>...[<head repo>:]<head branch>
// base<-head: master...head:feature
// same repo: master...feature
- infos := strings.Split(ctx.Params("*"), "...")
+
+ var (
+ headUser *models.User
+ headBranch string
+ isSameRepo bool
+ infoPath string
+ err error
+ )
+ infoPath, err = url.QueryUnescape(ctx.Params("*"))
+ if err != nil {
+ ctx.Handle(404, "QueryUnescape", err)
+ }
+ infos := strings.Split(infoPath, "...")
if len(infos) != 2 {
log.Trace("ParseCompareInfo[%d]: not enough compared branches information %s", baseRepo.ID, infos)
ctx.Handle(404, "CompareAndPullRequest", nil)
@@ -579,13 +592,6 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *
baseBranch := infos[0]
ctx.Data["BaseBranch"] = baseBranch
- var (
- headUser *models.User
- headBranch string
- isSameRepo bool
- err error
- )
-
// If there is no head repository, it means pull request between same repository.
headInfos := strings.Split(infos[1], ":")
if len(headInfos) == 1 {