Allow asterisk character in key names (#2487)

This commit is contained in:
Anis Elleuch 2016-08-18 20:00:01 +01:00 committed by Harshavardhana
parent 95c16f51cb
commit 73d1a46f3e
4 changed files with 6 additions and 6 deletions

View File

@ -118,7 +118,7 @@ const (
ErrFilterNameInvalid
ErrFilterNamePrefix
ErrFilterNameSuffix
ErrFilterPrefixValueInvalid
ErrFilterValueInvalid
// S3 extended errors.
ErrContentSHA256Mismatch
@ -500,9 +500,9 @@ var errorCodeResponse = map[APIErrorCode]APIError{
Description: "Cannot specify more than one suffix rule in a filter.",
HTTPStatusCode: http.StatusBadRequest,
},
ErrFilterPrefixValueInvalid: {
ErrFilterValueInvalid: {
Code: "InvalidArgument",
Description: "prefix rule value cannot exceed 1024 characters",
Description: "Size of filter rule value cannot exceed 1024 bytes in UTF-8 representation",
HTTPStatusCode: http.StatusBadRequest,
},

View File

@ -88,9 +88,8 @@ func checkFilterRules(filterRules []filterRule) APIErrorCode {
}
}
// Maximum prefix length can be up to 1,024 characters, validate.
if !IsValidObjectPrefix(filterRule.Value) {
return ErrFilterPrefixValueInvalid
return ErrFilterValueInvalid
}
// Set the new rule name to keep track of duplicates.

View File

@ -103,7 +103,7 @@ func IsValidObjectPrefix(object string) bool {
return false
}
// Reject unsupported characters in object name.
if strings.ContainsAny(object, "`^*|\\\"") {
if strings.ContainsAny(object, "`^|\\\"") {
return false
}
return true

View File

@ -88,6 +88,7 @@ func TestIsValidObjectName(t *testing.T) {
{"Cost Benefit Analysis (2009-2010).pptx", true},
{"117Gn8rfHL2ACARPAhaFd0AGzic9pUbIA/5OCn5A", true},
{"SHØRT", true},
{"f*le", true},
{"There are far too many object names, and far too few bucket names!", true},
// cases for which test should fail.
// passing invalid object names.