Moving from govendor to dep, updated dependencies (#48)

* Moving from govendor to dep.

* Making the pull request template more friendly.

* Fixing akward space in PR template.

* goimports run on whole project using ` goimports -w $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./gen-go/*")`

source of command: https://gist.github.com/bgentry/fd1ffef7dbde01857f66
This commit is contained in:
Renan DelValle 2018-01-07 13:13:47 -08:00 committed by GitHub
parent 9631aa3aab
commit 8d445c1c77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2186 changed files with 400410 additions and 352 deletions

View file

@ -7,6 +7,7 @@ import (
"math/rand"
"strconv"
"strings"
"unicode/utf8"
)
// AuthACL produces an ACL list containing a single ACL which uses the
@ -52,3 +53,64 @@ func stringShuffle(s []string) {
s[i], s[j] = s[j], s[i]
}
}
// validatePath will make sure a path is valid before sending the request
func validatePath(path string, isSequential bool) error {
if path == "" {
return ErrInvalidPath
}
if path[0] != '/' {
return ErrInvalidPath
}
n := len(path)
if n == 1 {
// path is just the root
return nil
}
if !isSequential && path[n-1] == '/' {
return ErrInvalidPath
}
// Start at rune 1 since we already know that the first character is
// a '/'.
for i, w := 1, 0; i < n; i += w {
r, width := utf8.DecodeRuneInString(path[i:])
switch {
case r == '\u0000':
return ErrInvalidPath
case r == '/':
last, _ := utf8.DecodeLastRuneInString(path[:i])
if last == '/' {
return ErrInvalidPath
}
case r == '.':
last, lastWidth := utf8.DecodeLastRuneInString(path[:i])
// Check for double dot
if last == '.' {
last, _ = utf8.DecodeLastRuneInString(path[:i-lastWidth])
}
if last == '/' {
if i+1 == n {
return ErrInvalidPath
}
next, _ := utf8.DecodeRuneInString(path[i+w:])
if next == '/' {
return ErrInvalidPath
}
}
case r >= '\u0000' && r <= '\u001f',
r >= '\u007f' && r <= '\u009f',
r >= '\uf000' && r <= '\uf8ff',
r >= '\ufff0' && r < '\uffff':
return ErrInvalidPath
}
w = width
}
return nil
}