mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
fix(smtp): support UTF-8 subjects (#7432)
fix(smtp): support utf8 subjects
This commit is contained in:
parent
ffdde825ec
commit
a88662bb3a
@ -2,6 +2,7 @@ package messages
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"mime"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -54,7 +55,7 @@ func (msg *Email) GetContent() (string, error) {
|
|||||||
if !isHTML(msg.Content) {
|
if !isHTML(msg.Content) {
|
||||||
mime = "MIME-version: 1.0;" + lineBreak + "Content-Type: text/plain; charset=\"UTF-8\";" + lineBreak + lineBreak
|
mime = "MIME-version: 1.0;" + lineBreak + "Content-Type: text/plain; charset=\"UTF-8\";" + lineBreak + lineBreak
|
||||||
}
|
}
|
||||||
subject := "Subject: " + qEncodeSubject(msg.Subject) + lineBreak
|
subject := "Subject: " + bEncodeSubject(msg.Subject) + lineBreak
|
||||||
message += subject + mime + lineBreak + msg.Content
|
message += subject + mime + lineBreak + msg.Content
|
||||||
|
|
||||||
return message, nil
|
return message, nil
|
||||||
@ -68,7 +69,7 @@ func isHTML(input string) bool {
|
|||||||
return isHTMLRgx.MatchString(input)
|
return isHTMLRgx.MatchString(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns a RFC1342 "Q" encoded string to allow non-ascii characters
|
// returns a RFC1342 "B" encoded string to allow non-ascii characters
|
||||||
func qEncodeSubject(subject string) string {
|
func bEncodeSubject(subject string) string {
|
||||||
return "=?utf-8?q?" + subject + "?="
|
return mime.BEncoding.Encode("UTF-8", subject)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user