From dc0913b252be4c4f4dfb905e2561cf58d2c00509 Mon Sep 17 00:00:00 2001 From: Joe Blubaugh Date: Thu, 22 Sep 2022 20:41:25 +0800 Subject: [PATCH] EmailConfig: Use CanonicalMIMEHeaderKey instead of TitleCasing for headers (#3080) * EmailConfig: Use CanonicalMIMEHeaderKey instead of TitleCasing for headers Fixes #3064. Signed-off-by: Joe Blubaugh * Remove an unused field. Signed-off-by: Joe Blubaugh Signed-off-by: Joe Blubaugh --- config/notifiers.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/config/notifiers.go b/config/notifiers.go index 28aaa780..7b6f7197 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -15,6 +15,7 @@ package config import ( "fmt" + "net/textproto" "regexp" "strings" "time" @@ -22,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 ( @@ -147,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. @@ -194,7 +191,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) }