reject object names with '\' on windows (#16856)

This commit is contained in:
Harshavardhana
2023-03-20 13:16:00 -07:00
committed by GitHub
parent 6c11dbffd5
commit b3c54ec81e
3 changed files with 72 additions and 6 deletions

View File

@@ -174,10 +174,7 @@ func IsValidObjectPrefix(object string) bool {
// work with file systems, we will reject here
// to return object name invalid rather than
// a cryptic error from the file system.
if strings.ContainsRune(object, 0) {
return false
}
return true
return !strings.ContainsRune(object, 0)
}
// checkObjectNameForLengthAndSlash -check for the validity of object name length and prefis as slash
@@ -199,7 +196,7 @@ func checkObjectNameForLengthAndSlash(bucket, object string) error {
if runtime.GOOS == globalWindowsOSName {
// Explicitly disallowed characters on windows.
// Avoids most problematic names.
if strings.ContainsAny(object, `:*?"|<>`) {
if strings.ContainsAny(object, `\:*?"|<>`) {
return ObjectNameInvalid{
Bucket: bucket,
Object: object,