Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmailConfig: Use CanonicalMIMEHeaderKey instead of TitleCasing for headers #3080

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions config/notifiers.go
Expand Up @@ -15,15 +15,14 @@ package config

import (
"fmt"
"net/textproto"
"regexp"
"strings"
"time"

"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 (
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
Expand Down