api: Fix verification of checkLeafDirectory. (#1347)

This fixes a problem where leaf directory has more than 1000
entries, also resulting in listing issues, leading to an infinite
loop.

Fixes #1334
This commit is contained in:
Harshavardhana
2016-04-21 18:05:26 -07:00
parent cb1116725b
commit 1284ecc6f2
3 changed files with 34 additions and 24 deletions

View File

@@ -23,10 +23,6 @@ import (
"unicode/utf8"
)
const (
slashPathSeparator = "/"
)
// validBucket regexp.
var validBucket = regexp.MustCompile(`^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$`)
@@ -91,8 +87,17 @@ func IsValidObjectPrefix(object string) bool {
}
func pathJoin(path1 string, path2 string) string {
return strings.TrimSuffix(path1, slashPathSeparator) + slashPathSeparator + path2
// Slash separator.
const slashSeparator = "/"
// retainSlash - retains slash from a path.
func retainSlash(s string) string {
return strings.TrimSuffix(s, slashSeparator) + slashSeparator
}
// pathJoin - path join.
func pathJoin(s1 string, s2 string) string {
return retainSlash(s1) + s2
}
// validates location constraint from the request body.