Skip to content

Commit bcbf045

Browse files
authored
fix(sender): check writes in iMIP body (#1182)
1 parent df5e113 commit bcbf045

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

sender/sender.go

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,12 @@ func SendCalendarReply(account *config.Account, to []string, subject, plainBody
800800
return nil, err
801801
}
802802
qp := quotedprintable.NewWriter(plainPart)
803-
fmt.Fprint(qp, plainBody)
804-
qp.Close()
803+
if _, err := fmt.Fprint(qp, plainBody); err != nil {
804+
return nil, err
805+
}
806+
if err := qp.Close(); err != nil {
807+
return nil, err
808+
}
805809

806810
// text/calendar inline part (Outlook/Mac Mail use this)
807811
calHeader := textproto.MIMEHeader{}
@@ -811,10 +815,16 @@ func SendCalendarReply(account *config.Account, to []string, subject, plainBody
811815
if err != nil {
812816
return nil, err
813817
}
814-
calPart.Write([]byte(clib.WrapBase64(base64.StdEncoding.EncodeToString(icsData))))
818+
if _, err := calPart.Write([]byte(clib.WrapBase64(base64.StdEncoding.EncodeToString(icsData)))); err != nil {
819+
return nil, err
820+
}
815821

816-
altWriter.Close()
817-
altPart.Write(altMsg.Bytes())
822+
if err := altWriter.Close(); err != nil {
823+
return nil, err
824+
}
825+
if _, err := altPart.Write(altMsg.Bytes()); err != nil {
826+
return nil, err
827+
}
818828

819829
// .ics file attachment (Gmail uses this)
820830
attachHeader := textproto.MIMEHeader{}
@@ -825,10 +835,16 @@ func SendCalendarReply(account *config.Account, to []string, subject, plainBody
825835
if err != nil {
826836
return nil, err
827837
}
828-
attachPart.Write([]byte(clib.WrapBase64(base64.StdEncoding.EncodeToString(icsData))))
838+
if _, err := attachPart.Write([]byte(clib.WrapBase64(base64.StdEncoding.EncodeToString(icsData)))); err != nil {
839+
return nil, err
840+
}
829841

830-
outerWriter.Close()
831-
msg.Write(outerMsg.Bytes())
842+
if err := outerWriter.Close(); err != nil {
843+
return nil, err
844+
}
845+
if _, err := msg.Write(outerMsg.Bytes()); err != nil {
846+
return nil, err
847+
}
832848

833849
// Send via SMTP
834850
addr := fmt.Sprintf("%s:%d", smtpServer, smtpPort)

0 commit comments

Comments
 (0)