mirror of
https://github.com/minio/minio.git
synced 2025-11-10 05:59:43 -05:00
fs: Do not return reservedBucket names in ListBuckets() (#3754)
Make sure to skip reserved bucket names in `ListBuckets()` current code didn't skip this properly and also generalize this behavior for both XL and FS.
This commit is contained in:
@@ -129,7 +129,7 @@ func retainSlash(s string) string {
|
||||
func pathJoin(elem ...string) string {
|
||||
trailingSlash := ""
|
||||
if len(elem) > 0 {
|
||||
if strings.HasSuffix(elem[len(elem)-1], slashSeparator) {
|
||||
if hasSuffix(elem[len(elem)-1], slashSeparator) {
|
||||
trailingSlash = "/"
|
||||
}
|
||||
}
|
||||
@@ -180,6 +180,15 @@ func hasSuffix(s string, suffix string) bool {
|
||||
return strings.HasSuffix(s, suffix)
|
||||
}
|
||||
|
||||
// Ignores all reserved bucket names or invalid bucket names.
|
||||
func isReservedOrInvalidBucket(bucketEntry string) bool {
|
||||
bucketEntry = strings.TrimSuffix(bucketEntry, slashSeparator)
|
||||
if !IsValidBucketName(bucketEntry) {
|
||||
return true
|
||||
}
|
||||
return bucketEntry == minioMetaBucket || bucketEntry == minioReservedBucket
|
||||
}
|
||||
|
||||
// byBucketName is a collection satisfying sort.Interface.
|
||||
type byBucketName []BucketInfo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user