use correct headers for message part
Hello guys, on the hunt for bugs related to wrong encoding. This patch is fixing reply to non-utf8 messages. We were using global message headers instead of part specific. In practice header were often something like: multipart; boundry=... where there should be: text/plain; charset=... Fixed also missing SubType. Have great weekend! Leszek
This commit is contained in:
parent
0a1a75aed1
commit
30aa77c1c9
|
@ -157,10 +157,38 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
|
|
||||||
store.FetchBodyPart(msg.Uid, []int{1}, func(reader io.Reader) {
|
store.FetchBodyPart(msg.Uid, []int{1}, func(reader io.Reader) {
|
||||||
header := message.Header{}
|
header := message.Header{}
|
||||||
header.SetText(
|
if len(msg.BodyStructure.Parts) > 0 {
|
||||||
"Content-Transfer-Encoding", msg.BodyStructure.Encoding)
|
partID := 0 // TODO: will we always choose first msg part?
|
||||||
header.SetContentType(msg.BodyStructure.MIMEType, msg.BodyStructure.Params)
|
header.SetText(
|
||||||
header.SetText("Content-Description", msg.BodyStructure.Description)
|
"Content-Transfer-Encoding", msg.BodyStructure.Parts[partID].Encoding)
|
||||||
|
if msg.BodyStructure.Parts[partID].MIMESubType == "" {
|
||||||
|
header.SetContentType(
|
||||||
|
msg.BodyStructure.Parts[partID].MIMEType,
|
||||||
|
msg.BodyStructure.Parts[partID].Params)
|
||||||
|
} else {
|
||||||
|
// include SubType if defined (text/plain, text/html, ...)
|
||||||
|
header.SetContentType(
|
||||||
|
fmt.Sprintf("%s/%s", msg.BodyStructure.Parts[partID].MIMEType,
|
||||||
|
msg.BodyStructure.Parts[partID].MIMESubType),
|
||||||
|
msg.BodyStructure.Parts[partID].Params)
|
||||||
|
}
|
||||||
|
header.SetText("Content-Description", msg.BodyStructure.Parts[partID].Description)
|
||||||
|
} else { // Parts has no headers, so we use global headers info
|
||||||
|
header.SetText(
|
||||||
|
"Content-Transfer-Encoding", msg.BodyStructure.Encoding)
|
||||||
|
if msg.BodyStructure.MIMESubType == "" {
|
||||||
|
header.SetContentType(
|
||||||
|
msg.BodyStructure.MIMEType,
|
||||||
|
msg.BodyStructure.Params)
|
||||||
|
} else {
|
||||||
|
// include SubType if defined (text/plain, text/html, ...)
|
||||||
|
header.SetContentType(
|
||||||
|
fmt.Sprintf("%s/%s", msg.BodyStructure.MIMEType,
|
||||||
|
msg.BodyStructure.MIMESubType),
|
||||||
|
msg.BodyStructure.Params)
|
||||||
|
}
|
||||||
|
header.SetText("Content-Description", msg.BodyStructure.Description)
|
||||||
|
}
|
||||||
entity, err := message.New(header, reader)
|
entity, err := message.New(header, reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: Do something with the error
|
// TODO: Do something with the error
|
||||||
|
|
Loading…
Reference in New Issue