Skip to content

Commit

Permalink
Merge branch 'coypoop-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dusan Kasan authored and Dusan Kasan committed Apr 4, 2020
2 parents 6e5c9f9 + e97c2f2 commit 28dfb22
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions parsemail.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ func parseMultipartMixed(msg io.Reader, boundary string) (textBody, htmlBody str
if err != nil {
return textBody, htmlBody, attachments, embeddedFiles, err
}
} else if contentType == contentTypeTextPlain {
ppContent, err := ioutil.ReadAll(part)
if err != nil {
return textBody, htmlBody, attachments, embeddedFiles, err
}

textBody += strings.TrimSuffix(string(ppContent[:]), "\n")
} else if isAttachment(part) {
at, err := decodeAttachment(part)
if err != nil {
Expand Down
32 changes: 32 additions & 0 deletions parsemail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,25 @@ So, "Hello".`,
contentType: `image/jpeg; x-unix-mode=0644; name="image.gif"`,
content: `GIF89a;`,
},
9: {
contentType: `multipart/mixed; boundary="0000000000007e2bb40587e36196"`,
mailData: textPlainInMultipart,
subject: "Re: kern/54143 (virtualbox)",
from: []mail.Address{
{
Name: "Rares",
Address: "rares@example.com",
},
},
to: []mail.Address{
{
Name: "",
Address: "bugs@example.com",
},
},
date: parseDate("Fri, 02 May 2019 11:25:35 +0300"),
textBody: `plain text part`,
},
}

for index, td := range testData {
Expand Down Expand Up @@ -626,6 +645,19 @@ YKUKF+Os3baUndC0pDnwNAmLy1SUr2Gw0luxQuV/AwC6cEhVV5VRrwAAAABJRU5ErkJggg==
--------------C70C0458A558E585ACB75FB4--
`

var textPlainInMultipart = `From: Rares <rares@example.com>
Date: Thu, 2 May 2019 11:25:35 +0300
Subject: Re: kern/54143 (virtualbox)
To: bugs@example.com
Content-Type: multipart/mixed; boundary="0000000000007e2bb40587e36196"
--0000000000007e2bb40587e36196
Content-Type: text/plain; charset="UTF-8"
plain text part
--0000000000007e2bb40587e36196--
`

var rfc5322exampleA11 = `From: John Doe <jdoe@machine.example>
Sender: Michael Jones <mjones@machine.example>
To: Mary Smith <mary@example.net>
Expand Down

0 comments on commit 28dfb22

Please sign in to comment.