From 200eb8dc0eed3889b594a8517c26e7f901f8a711 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 24 Aug 2021 21:13:37 -0700 Subject: [PATCH] fix: remove any internal metadata keys from notification (#13062) --- cmd/notification.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/notification.go b/cmd/notification.go index d5a26b3bb..5d4db4a36 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -1317,8 +1317,13 @@ func (args eventArgs) ToEvent(escape bool) event.Event { uniqueID := fmt.Sprintf("%X", eventTime.UnixNano()) respElements := map[string]string{ - "x-amz-request-id": args.RespElements["requestId"], - "x-minio-origin-endpoint": globalMinioEndpoint, // MinIO specific custom elements. + "x-amz-request-id": args.RespElements["requestId"], + "x-minio-origin-endpoint": func() string { + if globalMinioEndpoint != "" { + return globalMinioEndpoint + } + return getAPIEndpoints()[0] + }(), // MinIO specific custom elements. } // Add deployment as part of if globalDeploymentID != "" { @@ -1364,7 +1369,13 @@ func (args eventArgs) ToEvent(escape bool) event.Event { newEvent.S3.Object.ETag = args.Object.ETag newEvent.S3.Object.Size = args.Object.Size newEvent.S3.Object.ContentType = args.Object.ContentType - newEvent.S3.Object.UserMetadata = args.Object.UserDefined + newEvent.S3.Object.UserMetadata = make(map[string]string, len(args.Object.UserDefined)) + for k, v := range args.Object.UserDefined { + if strings.HasPrefix(strings.ToLower(k), ReservedMetadataPrefixLower) { + continue + } + newEvent.S3.Object.UserMetadata[k] = v + } } return newEvent