summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-11-20 01:18:50 -0500
committerUnknwon <u@gogs.io>2015-11-20 01:18:50 -0500
commit902b5784659327a61ba7de56ef1885fcc6549b17 (patch)
tree8ddbe345e2140d300a20b74c47bd654ff728b096 /models
parent3d14e73fd835f2a0ed4a22daa4c67df245be8103 (diff)
downloadgitea-902b5784659327a61ba7de56ef1885fcc6549b17.tar.gz
gitea-902b5784659327a61ba7de56ef1885fcc6549b17.zip
better escape char handle
Diffstat (limited to 'models')
-rw-r--r--models/git_diff.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/models/git_diff.go b/models/git_diff.go
index 4cc9ebf8fa..4b1ec09ea8 100644
--- a/models/git_diff.go
+++ b/models/git_diff.go
@@ -163,10 +163,10 @@ func ParsePatch(pid int64, maxlines int, cmd *exec.Cmd, reader io.Reader) (*Diff
if strings.HasPrefix(line, DIFF_HEAD) {
middle := -1
- // Note: In case file name is surrounded by double quotes(it happens only in git-shell).
- hasQuote := strings.Index(line, `\"`) > -1
+ // Note: In case file name is surrounded by double quotes (it happens only in git-shell).
+ // e.g. diff --git "a/xxx" "b/xxx"
+ hasQuote := line[len(DIFF_HEAD)] == '"'
if hasQuote {
- line = strings.Replace(line, `\"`, `"`, -1)
middle = strings.Index(line, ` "b/`)
} else {
middle = strings.Index(line, " b/")
@@ -176,8 +176,8 @@ func ParsePatch(pid int64, maxlines int, cmd *exec.Cmd, reader io.Reader) (*Diff
a := line[beg+2 : middle]
b := line[middle+3:]
if hasQuote {
- a = a[1 : len(a)-1]
- b = b[1 : len(b)-1]
+ a = string(git.UnescapeChars([]byte(a[1 : len(a)-1])))
+ b = string(git.UnescapeChars([]byte(b[1 : len(b)-1])))
}
curFile = &DiffFile{