mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-29 09:32:16 +00:00
EmailConfig: Use CanonicalMIMEHeaderKey instead of TitleCasing for headers (#3080)
* EmailConfig: Use CanonicalMIMEHeaderKey instead of TitleCasing for headers Fixes #3064. Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com> * Remove an unused field. Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com> Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com>
This commit is contained in:
parent
efc956c7f7
commit
dc0913b252
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user