Parsing message with empty CC

This commit is contained in:
Michal Horejsek
2020-09-24 12:23:31 +02:00
parent fe926cbd57
commit ef1671d4ab
4 changed files with 27 additions and 0 deletions

View File

@ -4,6 +4,9 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
## Unreleased ## Unreleased
### Fixed
* GODT-752 Parsing message with empty CC.
## [IE 1.1.x] Danube (v1.1.0 beta 2020-09-XX) ## [IE 1.1.x] Danube (v1.1.0 beta 2020-09-XX)
### Fixed ### Fixed

View File

@ -152,6 +152,10 @@ func parseAddressComment(raw string) string {
} }
func parseAddressList(val string) (addrs []*mail.Address, err error) { func parseAddressList(val string) (addrs []*mail.Address, err error) {
if val == "" {
return
}
addrs, err = mail.ParseAddressList(parseAddressComment(val)) addrs, err = mail.ParseAddressList(parseAddressComment(val))
if err == nil { if err == nil {
if addrs == nil { if addrs == nil {

View File

@ -224,6 +224,21 @@ func TestParseTextPlainWithPlainAttachment(t *testing.T) {
assert.Equal(t, readerToString(attReaders[0]), "attachment") assert.Equal(t, readerToString(attReaders[0]), "attachment")
} }
func TestParseTextPlainEmptyCC(t *testing.T) {
f := getFileReader("text_plain_empty_cc.eml")
m, _, plainBody, attReaders, err := Parse(f, "", "")
require.NoError(t, err)
assert.Equal(t, `"Sender" <sender@pm.me>`, m.Sender.String())
assert.Equal(t, `"Receiver" <receiver@pm.me>`, m.ToList[0].String())
assert.Equal(t, "body", m.Body)
assert.Equal(t, "body", plainBody)
assert.Len(t, attReaders, 0)
}
func TestParseTextPlainWithImageInline(t *testing.T) { func TestParseTextPlainWithImageInline(t *testing.T) {
f := getFileReader("text_plain_image_inline.eml") f := getFileReader("text_plain_image_inline.eml")

View File

@ -0,0 +1,5 @@
From: Sender <sender@pm.me>
To: Receiver <receiver@pm.me>
CC:
body