|
|
@ -39,6 +39,7 @@ const ( |
|
|
|
|
|
|
|
|
|
|
|
// validBucket regexp.
|
|
|
|
// validBucket regexp.
|
|
|
|
var validBucket = regexp.MustCompile(`^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$`) |
|
|
|
var validBucket = regexp.MustCompile(`^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$`) |
|
|
|
|
|
|
|
var isIPAddress = regexp.MustCompile(`^(\d+\.){3}\d+$`) |
|
|
|
|
|
|
|
|
|
|
|
// IsValidBucketName verifies a bucket name in accordance with Amazon's
|
|
|
|
// IsValidBucketName verifies a bucket name in accordance with Amazon's
|
|
|
|
// requirements. It must be 3-63 characters long, can contain dashes
|
|
|
|
// requirements. It must be 3-63 characters long, can contain dashes
|
|
|
@ -51,7 +52,9 @@ func IsValidBucketName(bucket string) bool { |
|
|
|
if bucket[0] == '.' || bucket[len(bucket)-1] == '.' { |
|
|
|
if bucket[0] == '.' || bucket[len(bucket)-1] == '.' { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
return validBucket.MatchString(bucket) |
|
|
|
return (validBucket.MatchString(bucket) && |
|
|
|
|
|
|
|
!isIPAddress.MatchString(bucket) && |
|
|
|
|
|
|
|
!strings.Contains(bucket, "..")) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// IsValidObjectName verifies an object name in accordance with Amazon's
|
|
|
|
// IsValidObjectName verifies an object name in accordance with Amazon's
|
|
|
|