From 3b49a99b6088f2b1e1ba7539b4a69930dfb6de16 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 16 Feb 2017 11:47:54 -0500 Subject: [PATCH] wiki: fix crash with blob name contains tab (#3916) --- Makefile | 6 ++--- cmd/web.go | 2 +- vendor/github.com/gogits/git-module/README.md | 2 +- vendor/github.com/gogits/git-module/git.go | 2 +- vendor/github.com/gogits/git-module/tree.go | 24 +++++++++---------- vendor/vendor.json | 6 ++--- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 9b04e69e9..a71776ffa 100644 --- a/Makefile +++ b/Makefile @@ -70,11 +70,11 @@ test: go test -cover -race ./... fixme: - grep -rnw "FIXME" routers models modules + grep -rnw "FIXME" cmd routers models modules todo: - grep -rnw "TODO" routers models modules + grep -rnw "TODO" cmd routers models modules # Legacy code should be remove by the time of release legacy: - grep -rnw "LEGACY" routers models modules + grep -rnw "LEGACY" cmd routers models modules diff --git a/cmd/web.go b/cmd/web.go index 88ba397ec..aa4d84b0d 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -95,7 +95,7 @@ func checkVersion() { {"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"}, {"gopkg.in/ini.v1", ini.Version, "1.8.4"}, {"gopkg.in/macaron.v1", macaron.Version, "1.1.7"}, - {"github.com/gogits/git-module", git.Version, "0.4.8"}, + {"github.com/gogits/git-module", git.Version, "0.4.9"}, {"github.com/gogits/go-gogs-client", gogs.Version, "0.12.1"}, } for _, c := range checkers { diff --git a/vendor/github.com/gogits/git-module/README.md b/vendor/github.com/gogits/git-module/README.md index 2ced00d1e..9dedf5a98 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 f7a4d7fb9..9c95d45ef 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 50e65f682..789d4c9bf 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 } diff --git a/vendor/vendor.json b/vendor/vendor.json index fc3a2cae4..950f806e9 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -159,10 +159,10 @@ "revisionTime": "2016-08-10T03:50:02Z" }, { - "checksumSHA1": "PvpYCMEys67XcZPCZR27tRjnkHY=", + "checksumSHA1": "RSr3IvGo5PFxAP3ybtDcEojTWPI=", "path": "github.com/gogits/git-module", - "revision": "a6d3c3660265eece3a34aef4f6ec4ce29b543294", - "revisionTime": "2017-02-15T23:32:44Z" + "revision": "41f3ca26f6b202c82d022a1062f7b7ea6339924b", + "revisionTime": "2017-02-16T16:46:07Z" }, { "checksumSHA1": "xvG+RgJODQqlmdAkHUQK2TyLR88=",