server: fix object name trimmed if match with bucket name
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nugraha 2022-12-07 14:45:45 +07:00
parent 434b18cff8
commit e70c29a9ba
Signed by: ii64
GPG key ID: E41C08AD390E7C49

View file

@ -86,12 +86,10 @@ func (s *server) handle(ctx *fasthttp.RequestCtx) {
path := ctx.Path() path := ctx.Path()
_path := bytes.TrimLeft(path, "/") _path := bytes.TrimLeft(path, "/")
objectName := unsafeByteSliceToString(_path) objectName := unsafeByteSliceToString(_path)
if _, _objectName, found := bytes.Cut(_path, []byte(bucketName)); !isVirtualHostStyle &&
bytes.HasPrefix(_path, []byte(bucketName)) && s.logger.Debugw("handle",
found { "bucket", bucketName,
_objectName = bytes.TrimLeft(_objectName, "/") "objectName", objectName)
objectName = unsafeByteSliceToString(_objectName)
}
// check if we had access to the object // check if we had access to the object
if _, err := s.opts.S3.StatObject(ctx, bucketName, objectName, minio.GetObjectOptions{}); err != nil { if _, err := s.opts.S3.StatObject(ctx, bucketName, objectName, minio.GetObjectOptions{}); err != nil {