From 289de2a4c79ac02533b8d4af3901fcc68683d8c1 Mon Sep 17 00:00:00 2001 From: Joe Blubaugh Date: Wed, 21 Sep 2022 16:36:19 +0800 Subject: [PATCH 1/2] EmailConfig: Use CanonicalMIMEHeaderKey instead of TitleCasing for headers Fixes #3064. Signed-off-by: Joe Blubaugh --- config/notifiers.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/notifiers.go b/config/notifiers.go index 28aaa78057..b7ffdf17f1 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -15,6 +15,7 @@ package config import ( "fmt" + "net/textproto" "regexp" "strings" "time" @@ -194,7 +195,7 @@ func (c *EmailConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { // Header names are case-insensitive, check for collisions. normalizedHeaders := map[string]string{} for h, v := range c.Headers { - normalized := normalizeTitle.String(h) + normalized := textproto.CanonicalMIMEHeaderKey(h) if _, ok := normalizedHeaders[normalized]; ok { return fmt.Errorf("duplicate header %q in email config", normalized) } From ae1653b0cecc64b9ae21697c8684c3ef616e8dae Mon Sep 17 00:00:00 2001 From: Joe Blubaugh Date: Thu, 22 Sep 2022 13:33:24 +0800 Subject: [PATCH 2/2] Remove an unused field. Signed-off-by: Joe Blubaugh --- config/notifiers.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/notifiers.go b/config/notifiers.go index b7ffdf17f1..7b6f719720 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -23,8 +23,6 @@ import ( "github.com/pkg/errors" commoncfg "github.com/prometheus/common/config" "github.com/prometheus/common/sigv4" - "golang.org/x/text/cases" - "golang.org/x/text/language" ) var ( @@ -148,8 +146,6 @@ var ( Message: `{{ template "telegram.default.message" . }}`, ParseMode: "HTML", } - - normalizeTitle = cases.Title(language.AmericanEnglish) ) // NotifierConfig contains base options common across all notifier configurations.