fix(email): UTF-8 "Q" encode subject header (#6637)

fix(email): UTF-8 "Q" encode subject header
This commit is contained in:
Livio Spring 2023-09-29 10:53:45 +02:00 committed by GitHub
parent 68bfab2fb3
commit 2e99d0fe1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,7 +54,7 @@ func (msg *Email) GetContent() (string, error) {
if !isHTML(msg.Content) {
mime = "MIME-version: 1.0;" + lineBreak + "Content-Type: text/plain; charset=\"UTF-8\";" + lineBreak + lineBreak
}
subject := "Subject: " + msg.Subject + lineBreak
subject := "Subject: " + qEncodeSubject(msg.Subject) + lineBreak
message += subject + mime + lineBreak + msg.Content
return message, nil
@ -67,3 +67,8 @@ func (msg *Email) GetTriggeringEvent() eventstore.Event {
func isHTML(input string) bool {
return isHTMLRgx.MatchString(input)
}
// returns a RFC1342 "Q" encoded string to allow non-ascii characters
func qEncodeSubject(subject string) string {
return "=?utf-8?q?" + subject + "?="
}