mirror of
https://github.com/minio/minio.git
synced 2025-11-20 01:50:24 -05:00
handle trimming '/' if present in the object names (#11765)
- MultipleDeletes should handle '/' prefix for objectnames - Trimming the slash alone is enough for ListObjects() prefix and markers fixes #11769
This commit is contained in:
26
cmd/utils.go
26
cmd/utils.go
@@ -687,6 +687,20 @@ func ceilFrac(numerator, denominator int64) (ceil int64) {
|
||||
return
|
||||
}
|
||||
|
||||
func trimLeadingSlash(ep string) string {
|
||||
if len(ep) > 0 && ep[0] == '/' {
|
||||
// Path ends with '/' preserve it
|
||||
if ep[len(ep)-1] == '/' && len(ep) > 1 {
|
||||
ep = path.Clean(ep)
|
||||
ep += slashSeparator
|
||||
} else {
|
||||
ep = path.Clean(ep)
|
||||
}
|
||||
ep = ep[1:]
|
||||
}
|
||||
return ep
|
||||
}
|
||||
|
||||
// unescapeGeneric is similar to url.PathUnescape or url.QueryUnescape
|
||||
// depending on input, additionally also handles situations such as
|
||||
// `//` are normalized as `/`, also removes any `/` prefix before
|
||||
@@ -696,17 +710,7 @@ func unescapeGeneric(p string, escapeFn func(string) (string, error)) (string, e
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(ep) > 0 && ep[0] == '/' {
|
||||
// Path ends with '/' preserve it
|
||||
if ep[len(ep)-1] == '/' {
|
||||
ep = path.Clean(ep)
|
||||
ep += slashSeparator
|
||||
} else {
|
||||
ep = path.Clean(ep)
|
||||
}
|
||||
ep = ep[1:]
|
||||
}
|
||||
return ep, nil
|
||||
return trimLeadingSlash(ep), nil
|
||||
}
|
||||
|
||||
// unescapePath is similar to unescapeGeneric but for specifically
|
||||
|
||||
Reference in New Issue
Block a user