From e5d63edb62ddf5e316135f8f81b62bda8a5a068e Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Tue, 12 May 2020 08:05:36 +0200 Subject: [PATCH] test: add message.Parse tests --- pkg/message/parser.go | 28 +- pkg/message/parser_test.go | 316 ++++++++++++++++++ pkg/message/testdata/multiple_text_parts.b64 | 16 + pkg/message/testdata/multiple_text_parts.eml | 14 + pkg/message/testdata/text_html.b64 | 18 + pkg/message/testdata/text_html.eml | 5 + pkg/message/testdata/text_html_7bit.eml | 6 + pkg/message/testdata/text_html_7bit.mime | 19 ++ .../text_html_embedded_foreign_encoding.b64 | 18 + .../text_html_embedded_foreign_encoding.eml | 5 + .../testdata/text_html_image_inline.b64 | 52 +++ .../testdata/text_html_image_inline.eml | 35 ++ .../testdata/text_html_octet_attachment.b64 | 31 ++ .../testdata/text_html_octet_attachment.eml | 14 + .../testdata/text_html_plain_attachment.b64 | 18 + .../testdata/text_html_plain_attachment.eml | 13 + pkg/message/testdata/text_plain.b64 | 5 + pkg/message/testdata/text_plain.eml | 4 + pkg/message/testdata/text_plain_7bit.eml | 5 + pkg/message/testdata/text_plain_7bit.mime | 5 + .../testdata/text_plain_image_inline.b64 | 38 +++ .../testdata/text_plain_image_inline.eml | 34 ++ pkg/message/testdata/text_plain_latin1.b64 | 6 + pkg/message/testdata/text_plain_latin1.eml | 5 + .../testdata/text_plain_octet_attachment.b64 | 17 + .../testdata/text_plain_octet_attachment.eml | 13 + .../testdata/text_plain_plain_attachment.b64 | 17 + .../testdata/text_plain_plain_attachment.eml | 12 + pkg/message/testdata/text_plain_pubkey.b64 | 19 ++ .../testdata/text_plain_unknown_latin1.b64 | 6 + .../testdata/text_plain_unknown_latin1.eml | 5 + .../testdata/text_plain_unknown_latin2.b64 | 6 + .../testdata/text_plain_unknown_latin2.eml | 5 + pkg/message/testdata/text_plain_utf8.b64 | 6 + pkg/message/testdata/text_plain_utf8.eml | 5 + 35 files changed, 808 insertions(+), 13 deletions(-) create mode 100644 pkg/message/testdata/multiple_text_parts.b64 create mode 100644 pkg/message/testdata/multiple_text_parts.eml create mode 100644 pkg/message/testdata/text_html.b64 create mode 100644 pkg/message/testdata/text_html.eml create mode 100644 pkg/message/testdata/text_html_7bit.eml create mode 100644 pkg/message/testdata/text_html_7bit.mime create mode 100644 pkg/message/testdata/text_html_embedded_foreign_encoding.b64 create mode 100644 pkg/message/testdata/text_html_embedded_foreign_encoding.eml create mode 100644 pkg/message/testdata/text_html_image_inline.b64 create mode 100644 pkg/message/testdata/text_html_image_inline.eml create mode 100644 pkg/message/testdata/text_html_octet_attachment.b64 create mode 100644 pkg/message/testdata/text_html_octet_attachment.eml create mode 100644 pkg/message/testdata/text_html_plain_attachment.b64 create mode 100644 pkg/message/testdata/text_html_plain_attachment.eml create mode 100644 pkg/message/testdata/text_plain.b64 create mode 100644 pkg/message/testdata/text_plain.eml create mode 100644 pkg/message/testdata/text_plain_7bit.eml create mode 100644 pkg/message/testdata/text_plain_7bit.mime create mode 100644 pkg/message/testdata/text_plain_image_inline.b64 create mode 100644 pkg/message/testdata/text_plain_image_inline.eml create mode 100644 pkg/message/testdata/text_plain_latin1.b64 create mode 100644 pkg/message/testdata/text_plain_latin1.eml create mode 100644 pkg/message/testdata/text_plain_octet_attachment.b64 create mode 100644 pkg/message/testdata/text_plain_octet_attachment.eml create mode 100644 pkg/message/testdata/text_plain_plain_attachment.b64 create mode 100644 pkg/message/testdata/text_plain_plain_attachment.eml create mode 100644 pkg/message/testdata/text_plain_pubkey.b64 create mode 100644 pkg/message/testdata/text_plain_unknown_latin1.b64 create mode 100644 pkg/message/testdata/text_plain_unknown_latin1.eml create mode 100644 pkg/message/testdata/text_plain_unknown_latin2.b64 create mode 100644 pkg/message/testdata/text_plain_unknown_latin2.eml create mode 100644 pkg/message/testdata/text_plain_utf8.b64 create mode 100644 pkg/message/testdata/text_plain_utf8.eml diff --git a/pkg/message/parser.go b/pkg/message/parser.go index 6e23d056..d46e3d17 100644 --- a/pkg/message/parser.go +++ b/pkg/message/parser.go @@ -19,15 +19,14 @@ package message import ( "bytes" - "crypto/rand" "crypto/sha256" "encoding/base64" "encoding/hex" "fmt" "io" "io/ioutil" + "math/rand" "mime" - "mime/quotedprintable" "net/mail" "net/textproto" "regexp" @@ -186,7 +185,7 @@ func checkHeaders(headers []textproto.MIMEHeader) bool { // ============================== 7bit Filter ========================== // For every MIME part in the tree that has "8bit" or "binary" content -// transfer encoding: transcode it to "quoted-printable". +// transfer encoding: transcode it to "base64". type SevenBitFilter struct { target pmmime.VisitAcceptor @@ -216,18 +215,16 @@ func (sd SevenBitFilter) Accept(partReader io.Reader, header textproto.MIMEHeade for k, v := range header { filteredHeader[k] = v } - filteredHeader.Set("Content-Transfer-Encoding", "quoted-printable") - //filteredHeader.Set("Content-Transfer-Encoding", "base64") + filteredHeader.Set("Content-Transfer-Encoding", "base64") filteredBuffer := &bytes.Buffer{} decodedSlice, _ := ioutil.ReadAll(decodedPart) - w := quotedprintable.NewWriter(filteredBuffer) - //w := base64.NewEncoder(base64.StdEncoding, filteredBuffer) + w := base64.NewEncoder(base64.StdEncoding, filteredBuffer) if _, err := w.Write(decodedSlice); err != nil { - log.Errorf("cannot write quotedprintable from %q: %v", cte, err) + log.Errorf("cannot write base64 from %q: %v", cte, err) } if err := w.Close(); err != nil { - log.Errorf("cannot close quotedprintable from %q: %v", cte, err) + log.Errorf("cannot close base64 from %q: %v", cte, err) } _ = sd.target.Accept(filteredBuffer, filteredHeader, hasPlainSibling, true, isLast) @@ -252,13 +249,15 @@ func NewHTMLOnlyConvertor(targetAccepter pmmime.VisitAcceptor) *HTMLOnlyConverto } func randomBoundary() string { - var buf [30]byte - _, err := io.ReadFull(rand.Reader, buf[:]) - if err != nil { + buf := make([]byte, 30) + + // We specifically use `math/rand` here to allow the generator to be seeded for test purposes. + // The random numbers need not be cryptographically secure; we are simply generating random part boundaries. + if _, err := rand.Read(buf); err != nil { // nolint[gosec] panic(err) } - return fmt.Sprintf("%x", buf[:]) + return fmt.Sprintf("%x", buf) } func (hoc HTMLOnlyConvertor) Accept(partReader io.Reader, header textproto.MIMEHeader, hasPlainSiblings bool, isFirst, isLast bool) error { @@ -364,6 +363,8 @@ func (pka *PublicKeyAttacher) Accept(partReader io.Reader, header textproto.MIME }() } isRoot := (header.Get("From") != "") + + // NOTE: This should also work for unspecified Content-Type (in which case us-ascii text/plain is assumed)! mediaType, _, err := pmmime.ParseMediaType(header.Get("Content-Type")) if isRoot && isFirst && err == nil && pka.attachedPublicKey != "" { //nolint[gocritic] if strings.HasPrefix(mediaType, "multipart/mixed") { @@ -447,6 +448,7 @@ func Parse(r io.Reader, attachedPublicKey, attachedPublicKeyName string) (m *pma } mimeBody = printAccepter.String() + plainContents = plainTextCollector.GetPlainText() parts, headers, err := pmmime.GetAllChildParts(bytes.NewReader(mmBodyData), h) diff --git a/pkg/message/parser_test.go b/pkg/message/parser_test.go index 58305562..29273f83 100644 --- a/pkg/message/parser_test.go +++ b/pkg/message/parser_test.go @@ -18,8 +18,17 @@ package message import ( + "image/png" + "io" + "io/ioutil" + "math/rand" "net/mail" + "os" + "path/filepath" "testing" + + "github.com/stretchr/testify/assert" + "golang.org/x/text/encoding/charmap" ) func TestRFC822AddressFormat(t *testing.T) { //nolint[funlen] @@ -105,3 +114,310 @@ func TestRFC822AddressFormat(t *testing.T) { //nolint[funlen] } } } + +func f(filename string) io.Reader { + f, err := os.Open(filepath.Join("testdata", filename)) + + if err != nil { + panic(err) + } + + return f +} + +func s(filename string) string { + b, err := ioutil.ReadAll(f(filename)) + + if err != nil { + panic(err) + } + + return string(b) +} + +func readerToString(r io.Reader) string { + b, err := ioutil.ReadAll(r) + + if err != nil { + panic(err) + } + + return string(b) +} + +func TestParseMessageTextPlain(t *testing.T) { + m, mimeBody, plainContents, atts, err := Parse(f("text_plain.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "body", m.Body) + assert.Equal(t, s("text_plain.b64"), mimeBody) + assert.Equal(t, "body", plainContents) + + assert.Len(t, atts, 0) +} + +func TestParseMessageTextPlainUTF8(t *testing.T) { + m, mimeBody, plainContents, atts, err := Parse(f("text_plain_utf8.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "body", m.Body) + assert.Equal(t, s("text_plain_utf8.b64"), mimeBody) + assert.Equal(t, "body", plainContents) + + assert.Len(t, atts, 0) +} + +func TestParseMessageTextPlainLatin1(t *testing.T) { + m, mimeBody, plainContents, atts, err := Parse(f("text_plain_latin1.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "ééééééé", m.Body) + assert.Equal(t, s("text_plain_latin1.b64"), mimeBody) + assert.Equal(t, "ééééééé", plainContents) + + assert.Len(t, atts, 0) +} + +func TestParseMessageTextPlainUnknownCharsetIsActuallyLatin1(t *testing.T) { + m, mimeBody, plainContents, atts, err := Parse(f("text_plain_unknown_latin1.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "ééééééé", m.Body) + assert.Equal(t, s("text_plain_unknown_latin1.b64"), mimeBody) + assert.Equal(t, "ééééééé", plainContents) + + assert.Len(t, atts, 0) +} + +func TestParseMessageTextPlainUnknownCharsetIsActuallyLatin2(t *testing.T) { + m, mimeBody, plainContents, atts, err := Parse(f("text_plain_unknown_latin2.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + // The file contains latin2-encoded text, but we will assume it is latin1 + // and decode it as such. This will lead to corruption. + latin2, _ := charmap.ISO8859_2.NewEncoder().Bytes([]byte("řšřšřš")) + expect, _ := charmap.ISO8859_1.NewDecoder().Bytes(latin2) + assert.NotEqual(t, []byte("řšřšřš"), expect) + + assert.Equal(t, string(expect), m.Body) + assert.Equal(t, s("text_plain_unknown_latin2.b64"), mimeBody) + assert.Equal(t, string(expect), plainContents) + + assert.Len(t, atts, 0) +} + +func TestParseMessageTextPlainAlready7Bit(t *testing.T) { + m, mimeBody, plainContents, atts, err := Parse(f("text_plain_7bit.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "body", m.Body) + assert.Equal(t, s("text_plain_7bit.mime"), mimeBody) + assert.Equal(t, "body", plainContents) + + assert.Len(t, atts, 0) +} + +func TestParseMessageTextPlainWithOctetAttachment(t *testing.T) { + m, mimeBody, plainContents, atts, err := Parse(f("text_plain_octet_attachment.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "body", m.Body) + assert.Equal(t, s("text_plain_octet_attachment.b64"), mimeBody) + assert.Equal(t, "body", plainContents) + + assert.Len(t, atts, 1) + assert.Equal(t, readerToString(atts[0]), "if you are reading this, hi!") +} + +func TestParseMessageTextPlainWithPlainAttachment(t *testing.T) { + m, mimeBody, plainContents, atts, err := Parse(f("text_plain_plain_attachment.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "body", m.Body) + assert.Equal(t, s("text_plain_plain_attachment.b64"), mimeBody) + assert.Equal(t, "body", plainContents) + + assert.Len(t, atts, 1) + assert.Equal(t, readerToString(atts[0]), "attachment") +} + +func TestParseMessageTextPlainWithImageInline(t *testing.T) { + m, mimeBody, plainContents, atts, err := Parse(f("text_plain_image_inline.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "body", m.Body) + assert.Equal(t, s("text_plain_image_inline.b64"), mimeBody) + assert.Equal(t, "body", plainContents) + + // The inline image is an 8x8 mic-dropping gopher. + assert.Len(t, atts, 1) + img, err := png.DecodeConfig(atts[0]) + assert.NoError(t, err) + assert.Equal(t, 8, img.Width) + assert.Equal(t, 8, img.Height) +} + +func TestParseMessageWithMultipleTextParts(t *testing.T) { + m, mimeBody, plainContents, atts, err := Parse(f("multiple_text_parts.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "body\nsome other part of the message", m.Body) + assert.Equal(t, s("multiple_text_parts.b64"), mimeBody) + assert.Equal(t, "body\nsome other part of the message", plainContents) + + assert.Len(t, atts, 0) +} + +func TestParseMessageTextHTML(t *testing.T) { + rand.Seed(0) + + m, mimeBody, plainContents, atts, err := Parse(f("text_html.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "This is body of HTML mail without attachment", m.Body) + assert.Equal(t, s("text_html.b64"), mimeBody) + assert.Equal(t, "This is body of *HTML mail* without attachment", plainContents) + + assert.Len(t, atts, 0) +} + +func TestParseMessageTextHTMLAlready7Bit(t *testing.T) { + rand.Seed(0) + + m, mimeBody, plainContents, atts, err := Parse(f("text_html_7bit.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "This is body of HTML mail without attachment", m.Body) + assert.Equal(t, s("text_html_7bit.mime"), mimeBody) + assert.Equal(t, "This is body of *HTML mail* without attachment", plainContents) + + assert.Len(t, atts, 0) +} + +func TestParseMessageTextHTMLWithOctetAttachment(t *testing.T) { + rand.Seed(0) + + m, mimeBody, plainContents, atts, err := Parse(f("text_html_octet_attachment.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "This is body of HTML mail with attachment", m.Body) + assert.Equal(t, s("text_html_octet_attachment.b64"), mimeBody) + assert.Equal(t, "This is body of *HTML mail* with attachment", plainContents) + + assert.Len(t, atts, 1) + assert.Equal(t, readerToString(atts[0]), "if you are reading this, hi!") +} + +// NOTE: Enable when bug is fixed. +func _TestParseMessageTextHTMLWithPlainAttachment(t *testing.T) { // nolint[deadcode] + rand.Seed(0) + + m, mimeBody, plainContents, atts, err := Parse(f("text_html_plain_attachment.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + // BAD: plainContents should not be empty! + assert.Equal(t, "This is body of HTML mail with attachment", m.Body) + assert.Equal(t, s("text_html_plain_attachment.b64"), mimeBody) + assert.Equal(t, "This is body of *HTML mail* with attachment", plainContents) + + assert.Len(t, atts, 1) + assert.Equal(t, readerToString(atts[0]), "attachment") +} + +func TestParseMessageTextHTMLWithImageInline(t *testing.T) { + rand.Seed(0) + + m, mimeBody, plainContents, atts, err := Parse(f("text_html_image_inline.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "This is body of HTML mail with attachment", m.Body) + assert.Equal(t, s("text_html_image_inline.b64"), mimeBody) + assert.Equal(t, "This is body of *HTML mail* with attachment", plainContents) + + // The inline image is an 8x8 mic-dropping gopher. + assert.Len(t, atts, 1) + img, err := png.DecodeConfig(atts[0]) + assert.NoError(t, err) + assert.Equal(t, 8, img.Width) + assert.Equal(t, 8, img.Height) +} + +// NOTE: Enable when bug is fixed. +func _TestParseMessageWithAttachedPublicKey(t *testing.T) { // nolint[deadcode] + // BAD: Public Key is not attached unless Content-Type is specified (not required)! + m, mimeBody, plainContents, atts, err := Parse(f("text_plain.eml"), "publickey", "publickeyname") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + assert.Equal(t, "body", m.Body) + assert.Equal(t, s("text_plain_pubkey.b64"), mimeBody) + assert.Equal(t, "body", plainContents) + + // BAD: Public key not available as an attachment! + assert.Len(t, atts, 1) +} + +// NOTE: Enable when bug is fixed. +func _TestParseMessageTextHTMLWithEmbeddedForeignEncoding(t *testing.T) { // nolint[deadcode] + rand.Seed(0) + + m, mimeBody, plainContents, atts, err := Parse(f("text_html_embedded_foreign_encoding.eml"), "", "") + assert.NoError(t, err) + + assert.Equal(t, `"Sender" `, m.Sender.String()) + assert.Equal(t, `"Receiver" `, m.ToList[0].String()) + + // BAD: Bridge does not detect the charset specified in the tag of the html. + assert.Equal(t, `latin2 řšřš`, m.Body) + assert.Equal(t, s("text_html_embedded_foreign_encoding.b64"), mimeBody) + assert.Equal(t, `latin2 řšřš`, plainContents) + + assert.Len(t, atts, 0) +} diff --git a/pkg/message/testdata/multiple_text_parts.b64 b/pkg/message/testdata/multiple_text_parts.b64 new file mode 100644 index 00000000..bf809ee5 --- /dev/null +++ b/pkg/message/testdata/multiple_text_parts.b64 @@ -0,0 +1,16 @@ +Content-Type: multipart/mixed; boundary=longrandomstring +From: Sender +To: Receiver + + +This is a multi-part message in MIME format. +--longrandomstring +Content-Transfer-Encoding: base64 + +Ym9keQo= +--longrandomstring +Content-Transfer-Encoding: base64 + +c29tZSBvdGhlciBwYXJ0IG9mIHRoZSBtZXNzYWdl +--longrandomstring-- +. diff --git a/pkg/message/testdata/multiple_text_parts.eml b/pkg/message/testdata/multiple_text_parts.eml new file mode 100644 index 00000000..1f12d029 --- /dev/null +++ b/pkg/message/testdata/multiple_text_parts.eml @@ -0,0 +1,14 @@ +From: Sender +To: Receiver +Content-Type: multipart/mixed; boundary=longrandomstring + +this part of the text should be ignored + +--longrandomstring + +body + +--longrandomstring + +some other part of the message +--longrandomstring-- \ No newline at end of file diff --git a/pkg/message/testdata/text_html.b64 b/pkg/message/testdata/text_html.b64 new file mode 100644 index 00000000..ed030352 --- /dev/null +++ b/pkg/message/testdata/text_html.b64 @@ -0,0 +1,18 @@ +Content-Type: multipart/alternative; boundary="0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d" +From: Sender +To: Receiver + + +This is a multi-part message in MIME format. +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d +Content-Transfer-Encoding: base64 +Content-Type: text/html + +PGh0bWw+PGJvZHk+VGhpcyBpcyBib2R5IG9mIDxiPkhUTUwgbWFpbDwvYj4gd2l0aG91dCBhdHRhY2htZW50PC9ib2R5PjwvaHRtbD4= +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d +Content-Transfer-Encoding: base64 +Content-Type: text/plain + +VGhpcyBpcyBib2R5IG9mICpIVE1MIG1haWwqIHdpdGhvdXQgYXR0YWNobWVudA== +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d-- +. diff --git a/pkg/message/testdata/text_html.eml b/pkg/message/testdata/text_html.eml new file mode 100644 index 00000000..efc764de --- /dev/null +++ b/pkg/message/testdata/text_html.eml @@ -0,0 +1,5 @@ +From: Sender +To: Receiver +Content-Type: text/html + +This is body of HTML mail without attachment \ No newline at end of file diff --git a/pkg/message/testdata/text_html_7bit.eml b/pkg/message/testdata/text_html_7bit.eml new file mode 100644 index 00000000..c73be952 --- /dev/null +++ b/pkg/message/testdata/text_html_7bit.eml @@ -0,0 +1,6 @@ +From: Sender +To: Receiver +Content-Type: text/html +Content-Transfer-Encoding: 7bit + +This is body of HTML mail without attachment \ No newline at end of file diff --git a/pkg/message/testdata/text_html_7bit.mime b/pkg/message/testdata/text_html_7bit.mime new file mode 100644 index 00000000..3e12d832 --- /dev/null +++ b/pkg/message/testdata/text_html_7bit.mime @@ -0,0 +1,19 @@ +Content-Transfer-Encoding: 7bit +Content-Type: multipart/alternative; boundary="0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d" +From: Sender +To: Receiver + + +This is a multi-part message in MIME format. +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d +Content-Transfer-Encoding: 7bit +Content-Type: text/html + +This is body of HTML mail without attachment +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d +Content-Transfer-Encoding: 7bit +Content-Type: text/plain + +This is body of *HTML mail* without attachment +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d-- +. diff --git a/pkg/message/testdata/text_html_embedded_foreign_encoding.b64 b/pkg/message/testdata/text_html_embedded_foreign_encoding.b64 new file mode 100644 index 00000000..308fbfd6 --- /dev/null +++ b/pkg/message/testdata/text_html_embedded_foreign_encoding.b64 @@ -0,0 +1,18 @@ +Content-Type: multipart/alternative; boundary="0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d" +From: Sender +To: Receiver + + +This is a multi-part message in MIME format. +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d +Content-Transfer-Encoding: base64 +Content-Type: text/html + +PGh0bWw+PGhlYWQ+PG1ldGEgY2hhcnNldD0iSVNPLTg4NTktMiI+PC9oZWFkPjxib2R5PmxhdGluMiD4ufi5PC9ib2R5PjwvaHRtbD4K +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d +Content-Transfer-Encoding: base64 +Content-Type: text/plain + +bGF0aW4yIO+/ve+/ve+/ve+/vQ== +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d-- +. diff --git a/pkg/message/testdata/text_html_embedded_foreign_encoding.eml b/pkg/message/testdata/text_html_embedded_foreign_encoding.eml new file mode 100644 index 00000000..2fcd12d2 --- /dev/null +++ b/pkg/message/testdata/text_html_embedded_foreign_encoding.eml @@ -0,0 +1,5 @@ +From: Sender +To: Receiver +Content-Type: text/html + +latin2 ø¹ø¹ diff --git a/pkg/message/testdata/text_html_image_inline.b64 b/pkg/message/testdata/text_html_image_inline.b64 new file mode 100644 index 00000000..797781b4 --- /dev/null +++ b/pkg/message/testdata/text_html_image_inline.b64 @@ -0,0 +1,52 @@ +Content-Type: multipart/mixed; boundary=longrandomstring +From: Sender +To: Receiver + + +This is a multi-part message in MIME format. +--longrandomstring +Content-Type: multipart/alternative; boundary="0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d" + + +This is a multi-part message in MIME format. +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d +Content-Transfer-Encoding: base64 +Content-Type: text/html + +PGh0bWw+PGJvZHk+VGhpcyBpcyBib2R5IG9mIDxiPkhUTUwgbWFpbDwvYj4gd2l0aCBhdHRhY2htZW50PC9ib2R5PjwvaHRtbD4= +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d +Content-Transfer-Encoding: base64 +Content-Type: text/plain + +VGhpcyBpcyBib2R5IG9mICpIVE1MIG1haWwqIHdpdGggYXR0YWNobWVudA== +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d-- +. + +--longrandomstring +Content-Disposition: inline +Content-Transfer-Encoding: base64 +Content-Type: image/png + +iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAABGdBTUEAALGPC/xhBQAAACBjSFJ +NAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFAR +IAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAA +ABaAAAAAAAAASwAAAABAAABLAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAACKADAAQAAAAB +AAAACAAAAAAAXWZ6AAAACXBIWXMAAC4jAAAuIwF4pT92AAACZmlUWHRYTUw6Y29tLmFkb2JlLnh +tcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIE +NvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5O +TkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91 +dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4 +wLyIKICAgICAgICAgICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leGlmLzEuMC +8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgI +CAgICA8dGlmZjpSZXNvbHV0aW9uVW5pdD4yPC90aWZmOlJlc29sdXRpb25Vbml0PgogICAgICAg +ICA8ZXhpZjpDb2xvclNwYWNlPjE8L2V4aWY6Q29sb3JTcGFjZT4KICAgICAgICAgPGV4aWY6UGl +4ZWxYRGltZW5zaW9uPjE2PC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6UG +l4ZWxZRGltZW5zaW9uPjE2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY +3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CgZBD4sAAAEISURBVBgZY2CAAO5F +x07Zz96xZ0Pn4lXqIKGGhgYmsFTHvAWdW6/dvnb89Yf/B5+9/r/y9IXzbVPahCH6/jMysfAJygo +JC2r++/T619Mb139J8HIb8Gs5hYMUzJ+/gJ1Jmo9H6c+L5wz3bt5iEeLmYOHn42fQ4vyacqGNQS +0xMfEHc7Cvl6CYho4rh5jUPyYefqafLKyMbH9+/d28/dFfdWtfDaZvTy7Zvv72nYGZkeEvw98/f +5j//2P4yCvxq/nU7zVs//8yM2gzMMitOnnu5cUff/8ff/v5/5Xf///vuHBhJcSRDAws9aEMr38c +W7XjNgvzexZ2rn9vbjx/IXl/M9iLM2fOZAUAKCZv7dU+UgAAAAAASUVORK5CYII= +--longrandomstring-- +. diff --git a/pkg/message/testdata/text_html_image_inline.eml b/pkg/message/testdata/text_html_image_inline.eml new file mode 100644 index 00000000..9a1b1534 --- /dev/null +++ b/pkg/message/testdata/text_html_image_inline.eml @@ -0,0 +1,35 @@ +From: Sender +To: Receiver +Content-Type: multipart/mixed; boundary=longrandomstring + +--longrandomstring +Content-Type: text/html + +This is body of HTML mail with attachment +--longrandomstring +Content-Type: image/png +Content-Disposition: inline +Content-Transfer-Encoding: base64 + +iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAABGdBTUEAALGPC/xhBQAAACBjSFJ +NAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFAR +IAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAA +ABaAAAAAAAAASwAAAABAAABLAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAACKADAAQAAAAB +AAAACAAAAAAAXWZ6AAAACXBIWXMAAC4jAAAuIwF4pT92AAACZmlUWHRYTUw6Y29tLmFkb2JlLnh +tcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIE +NvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5O +TkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91 +dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4 +wLyIKICAgICAgICAgICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leGlmLzEuMC +8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgI +CAgICA8dGlmZjpSZXNvbHV0aW9uVW5pdD4yPC90aWZmOlJlc29sdXRpb25Vbml0PgogICAgICAg +ICA8ZXhpZjpDb2xvclNwYWNlPjE8L2V4aWY6Q29sb3JTcGFjZT4KICAgICAgICAgPGV4aWY6UGl +4ZWxYRGltZW5zaW9uPjE2PC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6UG +l4ZWxZRGltZW5zaW9uPjE2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY +3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CgZBD4sAAAEISURBVBgZY2CAAO5F +x07Zz96xZ0Pn4lXqIKGGhgYmsFTHvAWdW6/dvnb89Yf/B5+9/r/y9IXzbVPahCH6/jMysfAJygo +JC2r++/T619Mb139J8HIb8Gs5hYMUzJ+/gJ1Jmo9H6c+L5wz3bt5iEeLmYOHn42fQ4vyacqGNQS +0xMfEHc7Cvl6CYho4rh5jUPyYefqafLKyMbH9+/d28/dFfdWtfDaZvTy7Zvv72nYGZkeEvw98/f +5j//2P4yCvxq/nU7zVs//8yM2gzMMitOnnu5cUff/8ff/v5/5Xf///vuHBhJcSRDAws9aEMr38c +W7XjNgvzexZ2rn9vbjx/IXl/M9iLM2fOZAUAKCZv7dU+UgAAAAAASUVORK5CYII= +--longrandomstring-- diff --git a/pkg/message/testdata/text_html_octet_attachment.b64 b/pkg/message/testdata/text_html_octet_attachment.b64 new file mode 100644 index 00000000..19f36aa8 --- /dev/null +++ b/pkg/message/testdata/text_html_octet_attachment.b64 @@ -0,0 +1,31 @@ +Content-Type: multipart/mixed; boundary=longrandomstring +From: Sender +To: Receiver + + +This is a multi-part message in MIME format. +--longrandomstring +Content-Type: multipart/alternative; boundary="0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d" + + +This is a multi-part message in MIME format. +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d +Content-Transfer-Encoding: base64 +Content-Type: text/html + +PGh0bWw+PGJvZHk+VGhpcyBpcyBib2R5IG9mIDxiPkhUTUwgbWFpbDwvYj4gd2l0aCBhdHRhY2htZW50PC9ib2R5PjwvaHRtbD4= +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d +Content-Transfer-Encoding: base64 +Content-Type: text/plain + +VGhpcyBpcyBib2R5IG9mICpIVE1MIG1haWwqIHdpdGggYXR0YWNobWVudA== +--0194fdc2fa2ffcc041d3ff12045b73c86e4ff95ff662a5eee82abdf44a2d-- +. + +--longrandomstring +Content-Transfer-Encoding: base64 +Content-Type: application/octet-stream + +aWYgeW91IGFyZSByZWFkaW5nIHRoaXMsIGhpIQ== +--longrandomstring-- +. diff --git a/pkg/message/testdata/text_html_octet_attachment.eml b/pkg/message/testdata/text_html_octet_attachment.eml new file mode 100644 index 00000000..b3476480 --- /dev/null +++ b/pkg/message/testdata/text_html_octet_attachment.eml @@ -0,0 +1,14 @@ +From: Sender +To: Receiver +Content-Type: multipart/mixed; boundary=longrandomstring + +--longrandomstring +Content-Type: text/html + +This is body of HTML mail with attachment +--longrandomstring +Content-Type: application/octet-stream +Content-Transfer-Encoding: base64 + +aWYgeW91IGFyZSByZWFkaW5nIHRoaXMsIGhpIQ== +--longrandomstring-- diff --git a/pkg/message/testdata/text_html_plain_attachment.b64 b/pkg/message/testdata/text_html_plain_attachment.b64 new file mode 100644 index 00000000..0283510f --- /dev/null +++ b/pkg/message/testdata/text_html_plain_attachment.b64 @@ -0,0 +1,18 @@ +Content-Type: multipart/mixed; boundary=longrandomstring +From: Sender +To: Receiver + + +This is a multi-part message in MIME format. +--longrandomstring +Content-Transfer-Encoding: base64 +Content-Type: text/html + +PGh0bWw+PGJvZHk+VGhpcyBpcyBib2R5IG9mIDxiPkhUTUwgbWFpbDwvYj4gd2l0aCBhdHRhY2htZW50PC9ib2R5PjwvaHRtbD4= +--longrandomstring +Content-Disposition: attachment +Content-Transfer-Encoding: base64 + +YXR0YWNobWVudA== +--longrandomstring-- +. diff --git a/pkg/message/testdata/text_html_plain_attachment.eml b/pkg/message/testdata/text_html_plain_attachment.eml new file mode 100644 index 00000000..98e5c019 --- /dev/null +++ b/pkg/message/testdata/text_html_plain_attachment.eml @@ -0,0 +1,13 @@ +From: Sender +To: Receiver +Content-Type: multipart/mixed; boundary=longrandomstring + +--longrandomstring +Content-Type: text/html + +This is body of HTML mail with attachment +--longrandomstring +Content-Disposition: attachment + +attachment +--longrandomstring-- diff --git a/pkg/message/testdata/text_plain.b64 b/pkg/message/testdata/text_plain.b64 new file mode 100644 index 00000000..02c0f613 --- /dev/null +++ b/pkg/message/testdata/text_plain.b64 @@ -0,0 +1,5 @@ +Content-Transfer-Encoding: base64 +From: Sender +To: Receiver + +Ym9keQ== \ No newline at end of file diff --git a/pkg/message/testdata/text_plain.eml b/pkg/message/testdata/text_plain.eml new file mode 100644 index 00000000..bb96c93e --- /dev/null +++ b/pkg/message/testdata/text_plain.eml @@ -0,0 +1,4 @@ +From: Sender +To: Receiver + +body \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_7bit.eml b/pkg/message/testdata/text_plain_7bit.eml new file mode 100644 index 00000000..ba74403a --- /dev/null +++ b/pkg/message/testdata/text_plain_7bit.eml @@ -0,0 +1,5 @@ +From: Sender +To: Receiver +Content-Transfer-Encoding: 7bit + +body \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_7bit.mime b/pkg/message/testdata/text_plain_7bit.mime new file mode 100644 index 00000000..8d8e4d94 --- /dev/null +++ b/pkg/message/testdata/text_plain_7bit.mime @@ -0,0 +1,5 @@ +Content-Transfer-Encoding: 7bit +From: Sender +To: Receiver + +body \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_image_inline.b64 b/pkg/message/testdata/text_plain_image_inline.b64 new file mode 100644 index 00000000..9bec5d03 --- /dev/null +++ b/pkg/message/testdata/text_plain_image_inline.b64 @@ -0,0 +1,38 @@ +Content-Type: multipart/related; boundary=longrandomstring +From: Sender +To: Receiver + + +This is a multi-part message in MIME format. +--longrandomstring +Content-Transfer-Encoding: base64 + +Ym9keQ== +--longrandomstring +Content-Disposition: inline +Content-Transfer-Encoding: base64 +Content-Type: image/png + +iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAABGdBTUEAALGPC/xhBQAAACBjSFJ +NAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFAR +IAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAA +ABaAAAAAAAAASwAAAABAAABLAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAACKADAAQAAAAB +AAAACAAAAAAAXWZ6AAAACXBIWXMAAC4jAAAuIwF4pT92AAACZmlUWHRYTUw6Y29tLmFkb2JlLnh +tcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIE +NvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5O +TkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91 +dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4 +wLyIKICAgICAgICAgICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leGlmLzEuMC +8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgI +CAgICA8dGlmZjpSZXNvbHV0aW9uVW5pdD4yPC90aWZmOlJlc29sdXRpb25Vbml0PgogICAgICAg +ICA8ZXhpZjpDb2xvclNwYWNlPjE8L2V4aWY6Q29sb3JTcGFjZT4KICAgICAgICAgPGV4aWY6UGl +4ZWxYRGltZW5zaW9uPjE2PC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6UG +l4ZWxZRGltZW5zaW9uPjE2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY +3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CgZBD4sAAAEISURBVBgZY2CAAO5F +x07Zz96xZ0Pn4lXqIKGGhgYmsFTHvAWdW6/dvnb89Yf/B5+9/r/y9IXzbVPahCH6/jMysfAJygo +JC2r++/T619Mb139J8HIb8Gs5hYMUzJ+/gJ1Jmo9H6c+L5wz3bt5iEeLmYOHn42fQ4vyacqGNQS +0xMfEHc7Cvl6CYho4rh5jUPyYefqafLKyMbH9+/d28/dFfdWtfDaZvTy7Zvv72nYGZkeEvw98/f +5j//2P4yCvxq/nU7zVs//8yM2gzMMitOnnu5cUff/8ff/v5/5Xf///vuHBhJcSRDAws9aEMr38c +W7XjNgvzexZ2rn9vbjx/IXl/M9iLM2fOZAUAKCZv7dU+UgAAAAAASUVORK5CYII= +--longrandomstring-- +. diff --git a/pkg/message/testdata/text_plain_image_inline.eml b/pkg/message/testdata/text_plain_image_inline.eml new file mode 100644 index 00000000..c0cb650f --- /dev/null +++ b/pkg/message/testdata/text_plain_image_inline.eml @@ -0,0 +1,34 @@ +From: Sender +To: Receiver +Content-Type: multipart/related; boundary=longrandomstring + +--longrandomstring + +body +--longrandomstring +Content-Type: image/png +Content-Disposition: inline +Content-Transfer-Encoding: base64 + +iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAABGdBTUEAALGPC/xhBQAAACBjSFJ +NAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFAR +IAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAA +ABaAAAAAAAAASwAAAABAAABLAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAACKADAAQAAAAB +AAAACAAAAAAAXWZ6AAAACXBIWXMAAC4jAAAuIwF4pT92AAACZmlUWHRYTUw6Y29tLmFkb2JlLnh +tcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIE +NvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5O +TkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91 +dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4 +wLyIKICAgICAgICAgICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leGlmLzEuMC +8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgI +CAgICA8dGlmZjpSZXNvbHV0aW9uVW5pdD4yPC90aWZmOlJlc29sdXRpb25Vbml0PgogICAgICAg +ICA8ZXhpZjpDb2xvclNwYWNlPjE8L2V4aWY6Q29sb3JTcGFjZT4KICAgICAgICAgPGV4aWY6UGl +4ZWxYRGltZW5zaW9uPjE2PC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6UG +l4ZWxZRGltZW5zaW9uPjE2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY +3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CgZBD4sAAAEISURBVBgZY2CAAO5F +x07Zz96xZ0Pn4lXqIKGGhgYmsFTHvAWdW6/dvnb89Yf/B5+9/r/y9IXzbVPahCH6/jMysfAJygo +JC2r++/T619Mb139J8HIb8Gs5hYMUzJ+/gJ1Jmo9H6c+L5wz3bt5iEeLmYOHn42fQ4vyacqGNQS +0xMfEHc7Cvl6CYho4rh5jUPyYefqafLKyMbH9+/d28/dFfdWtfDaZvTy7Zvv72nYGZkeEvw98/f +5j//2P4yCvxq/nU7zVs//8yM2gzMMitOnnu5cUff/8ff/v5/5Xf///vuHBhJcSRDAws9aEMr38c +W7XjNgvzexZ2rn9vbjx/IXl/M9iLM2fOZAUAKCZv7dU+UgAAAAAASUVORK5CYII= +--longrandomstring-- \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_latin1.b64 b/pkg/message/testdata/text_plain_latin1.b64 new file mode 100644 index 00000000..eff22363 --- /dev/null +++ b/pkg/message/testdata/text_plain_latin1.b64 @@ -0,0 +1,6 @@ +Content-Transfer-Encoding: base64 +Content-Type: text/plain; charset=ISO-8859-1 +From: Sender +To: Receiver + +6enp6enp6Q== \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_latin1.eml b/pkg/message/testdata/text_plain_latin1.eml new file mode 100644 index 00000000..dd8f88e0 --- /dev/null +++ b/pkg/message/testdata/text_plain_latin1.eml @@ -0,0 +1,5 @@ +From: Sender +To: Receiver +Content-Type: text/plain; charset=ISO-8859-1 + +ééééééé \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_octet_attachment.b64 b/pkg/message/testdata/text_plain_octet_attachment.b64 new file mode 100644 index 00000000..af92c48f --- /dev/null +++ b/pkg/message/testdata/text_plain_octet_attachment.b64 @@ -0,0 +1,17 @@ +Content-Type: multipart/mixed; boundary=longrandomstring +From: Sender +To: Receiver + + +This is a multi-part message in MIME format. +--longrandomstring +Content-Transfer-Encoding: base64 + +Ym9keQ== +--longrandomstring +Content-Transfer-Encoding: base64 +Content-Type: application/octet-stream + +aWYgeW91IGFyZSByZWFkaW5nIHRoaXMsIGhpIQ== +--longrandomstring-- +. diff --git a/pkg/message/testdata/text_plain_octet_attachment.eml b/pkg/message/testdata/text_plain_octet_attachment.eml new file mode 100644 index 00000000..87fd9287 --- /dev/null +++ b/pkg/message/testdata/text_plain_octet_attachment.eml @@ -0,0 +1,13 @@ +From: Sender +To: Receiver +Content-Type: multipart/mixed; boundary=longrandomstring + +--longrandomstring + +body +--longrandomstring +Content-Type: application/octet-stream +Content-Transfer-Encoding: base64 + +aWYgeW91IGFyZSByZWFkaW5nIHRoaXMsIGhpIQ== +--longrandomstring-- \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_plain_attachment.b64 b/pkg/message/testdata/text_plain_plain_attachment.b64 new file mode 100644 index 00000000..b732351c --- /dev/null +++ b/pkg/message/testdata/text_plain_plain_attachment.b64 @@ -0,0 +1,17 @@ +Content-Type: multipart/mixed; boundary=longrandomstring +From: Sender +To: Receiver + + +This is a multi-part message in MIME format. +--longrandomstring +Content-Transfer-Encoding: base64 + +Ym9keQ== +--longrandomstring +Content-Disposition: attachment +Content-Transfer-Encoding: base64 + +YXR0YWNobWVudA== +--longrandomstring-- +. diff --git a/pkg/message/testdata/text_plain_plain_attachment.eml b/pkg/message/testdata/text_plain_plain_attachment.eml new file mode 100644 index 00000000..6c894ebc --- /dev/null +++ b/pkg/message/testdata/text_plain_plain_attachment.eml @@ -0,0 +1,12 @@ +From: Sender +To: Receiver +Content-Type: multipart/mixed; boundary=longrandomstring + +--longrandomstring + +body +--longrandomstring +Content-Disposition: attachment + +attachment +--longrandomstring-- \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_pubkey.b64 b/pkg/message/testdata/text_plain_pubkey.b64 new file mode 100644 index 00000000..bf4b89f6 --- /dev/null +++ b/pkg/message/testdata/text_plain_pubkey.b64 @@ -0,0 +1,19 @@ +Content-Type: multipart/mixed; boundary="52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2" +From: Sender +To: Receiver + + +This is a multi-part message in MIME format. +--52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2 +Content-Transfer-Encoding: base64 + +Ym9keQ== +--52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2 +Content-Disposition: attachment; filename="publickeyname.asc.pgp" +Content-Transfer-Encoding: base64 +Content-Type: application/pgp-key; name="publickeyname" + +cHVibGlja2V5 + +--52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2-- +. diff --git a/pkg/message/testdata/text_plain_unknown_latin1.b64 b/pkg/message/testdata/text_plain_unknown_latin1.b64 new file mode 100644 index 00000000..b4ccee1f --- /dev/null +++ b/pkg/message/testdata/text_plain_unknown_latin1.b64 @@ -0,0 +1,6 @@ +Content-Transfer-Encoding: base64 +Content-Type: text/plain +From: Sender +To: Receiver + +6enp6enp6Q== \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_unknown_latin1.eml b/pkg/message/testdata/text_plain_unknown_latin1.eml new file mode 100644 index 00000000..2e1aa2cd --- /dev/null +++ b/pkg/message/testdata/text_plain_unknown_latin1.eml @@ -0,0 +1,5 @@ +From: Sender +To: Receiver +Content-Type: text/plain + +ééééééé \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_unknown_latin2.b64 b/pkg/message/testdata/text_plain_unknown_latin2.b64 new file mode 100644 index 00000000..94daaa7c --- /dev/null +++ b/pkg/message/testdata/text_plain_unknown_latin2.b64 @@ -0,0 +1,6 @@ +Content-Transfer-Encoding: base64 +Content-Type: text/plain +From: Sender +To: Receiver + ++Ln4ufi5 \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_unknown_latin2.eml b/pkg/message/testdata/text_plain_unknown_latin2.eml new file mode 100644 index 00000000..549a48a9 --- /dev/null +++ b/pkg/message/testdata/text_plain_unknown_latin2.eml @@ -0,0 +1,5 @@ +From: Sender +To: Receiver +Content-Type: text/plain + +ø¹ø¹ø¹ \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_utf8.b64 b/pkg/message/testdata/text_plain_utf8.b64 new file mode 100644 index 00000000..340ef7fa --- /dev/null +++ b/pkg/message/testdata/text_plain_utf8.b64 @@ -0,0 +1,6 @@ +Content-Transfer-Encoding: base64 +Content-Type: text/plain; charset=utf-8 +From: Sender +To: Receiver + +Ym9keQ== \ No newline at end of file diff --git a/pkg/message/testdata/text_plain_utf8.eml b/pkg/message/testdata/text_plain_utf8.eml new file mode 100644 index 00000000..924ad2fe --- /dev/null +++ b/pkg/message/testdata/text_plain_utf8.eml @@ -0,0 +1,5 @@ +From: Sender +To: Receiver +Content-Type: text/plain; charset=utf-8 + +body \ No newline at end of file