handle non-ascii subjects
This commit is contained in:
parent
ca1e6261e9
commit
e816fe2f60
|
@ -84,6 +84,11 @@ func normalize(m []byte, encoding string) ([]byte, error) {
|
|||
return s, err
|
||||
}
|
||||
|
||||
func decodeSubject(subject string) (string, error) {
|
||||
dec := new(mime.WordDecoder)
|
||||
return dec.DecodeHeader(subject)
|
||||
}
|
||||
|
||||
func getPlainParts(mail *mail.Message) ([]string, []error) {
|
||||
parts := make([]string, 0)
|
||||
errs := make([]error, 0)
|
||||
|
@ -156,7 +161,10 @@ func FetchPlaintext(p *Parameters) ([]string, []error) {
|
|||
date := mail.Header.Get("Date")
|
||||
from := mail.Header.Get("From")
|
||||
to := mail.Header.Get("To")
|
||||
subject := mail.Header.Get("Subject")
|
||||
subject, sErr := decodeSubject(mail.Header.Get("Subject"))
|
||||
if sErr != nil {
|
||||
errs = append(errs, sErr)
|
||||
}
|
||||
m := fmt.Sprintf("Date: %s\nFrom: %s\nTo: %s\nSubject: %s\n\n%s", date, from, to, subject, strings.Join(parts, "\n\n"))
|
||||
mailsPlain = append(mailsPlain, m)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user