diff options
author | Unknwon <u@gogs.io> | 2017-02-16 11:47:54 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-02-16 11:47:54 -0500 |
commit | 3b49a99b6088f2b1e1ba7539b4a69930dfb6de16 (patch) | |
tree | 783612222733d55eaa00661d9579a1bc0eea3482 /vendor/github.com/gogits/git-module | |
parent | f129e0ecb57634bc02972b7ff5a3175a829c0534 (diff) |
wiki: fix crash with blob name contains tab (#3916)
Diffstat (limited to 'vendor/github.com/gogits/git-module')
-rw-r--r-- | vendor/github.com/gogits/git-module/README.md | 2 | ||||
-rw-r--r-- | vendor/github.com/gogits/git-module/git.go | 2 | ||||
-rw-r--r-- | vendor/github.com/gogits/git-module/tree.go | 24 |
3 files changed, 13 insertions, 15 deletions
diff --git a/vendor/github.com/gogits/git-module/README.md b/vendor/github.com/gogits/git-module/README.md index 2ced00d1..9dedf5a9 100644 --- a/vendor/github.com/gogits/git-module/README.md +++ b/vendor/github.com/gogits/git-module/README.md @@ -4,7 +4,7 @@ Package git-module is a Go module for Git access through shell commands. ## Limitations -- Go version must be at least **1.3**. +- Go version must be at least **1.4**. - Git version must be no less than **1.7.1**, and greater than or equal to **1.8.0** is recommended. - For Windows users, try use as new a version as possible. diff --git a/vendor/github.com/gogits/git-module/git.go b/vendor/github.com/gogits/git-module/git.go index f7a4d7fb..9c95d45e 100644 --- a/vendor/github.com/gogits/git-module/git.go +++ b/vendor/github.com/gogits/git-module/git.go @@ -10,7 +10,7 @@ import ( "time" ) -const _VERSION = "0.4.8" +const _VERSION = "0.4.9" func Version() string { return _VERSION diff --git a/vendor/github.com/gogits/git-module/tree.go b/vendor/github.com/gogits/git-module/tree.go index 50e65f68..789d4c9b 100644 --- a/vendor/github.com/gogits/git-module/tree.go +++ b/vendor/github.com/gogits/git-module/tree.go @@ -29,25 +29,23 @@ func NewTree(repo *Repository, id sha1) *Tree { } } -var escapeChar = []byte("\\") +// Predefine []byte variables to avoid runtime allocations. +var ( + escapedSlash = []byte(`\\`) + regularSlash = []byte(`\`) + escapedTab = []byte(`\t`) + regularTab = []byte("\t") +) // UnescapeChars reverses escaped characters. func UnescapeChars(in []byte) []byte { - if bytes.Index(in, escapeChar) == -1 { + // LEGACY [Go 1.7]: use more expressive bytes.ContainsAny + if bytes.IndexAny(in, "\\\t") == -1 { return in } - endIdx := len(in) - 1 - isEscape := false - out := make([]byte, 0, endIdx+1) - for i := range in { - if in[i] == '\\' && !isEscape { - isEscape = true - continue - } - isEscape = false - out = append(out, in[i]) - } + out := bytes.Replace(in, escapedSlash, regularSlash, -1) + out = bytes.Replace(out, escapedTab, regularTab, -1) return out } |