Allow asterisk character in key names (#2487)

master
Anis Elleuch 8 years ago committed by Harshavardhana
parent 95c16f51cb
commit 73d1a46f3e
  1. 6
      api-errors.go
  2. 3
      bucket-notification-utils.go
  3. 2
      object-utils.go
  4. 1
      object-utils_test.go

@ -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,
},

@ -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.

@ -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

@ -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.

Loading…
Cancel
Save