mirror of
https://github.com/gogs/gogs.git
synced 2026-05-07 16:45:30 +02:00
wiki: fix crash with blob name contains tab (#3916)
This commit is contained in:
2
vendor/github.com/gogits/git-module/README.md
generated
vendored
2
vendor/github.com/gogits/git-module/README.md
generated
vendored
@@ -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.
|
||||
|
||||
|
||||
2
vendor/github.com/gogits/git-module/git.go
generated
vendored
2
vendor/github.com/gogits/git-module/git.go
generated
vendored
@@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const _VERSION = "0.4.8"
|
||||
const _VERSION = "0.4.9"
|
||||
|
||||
func Version() string {
|
||||
return _VERSION
|
||||
|
||||
24
vendor/github.com/gogits/git-module/tree.go
generated
vendored
24
vendor/github.com/gogits/git-module/tree.go
generated
vendored
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user