parent
060a5f4e98
commit
84856b343c
|
@ -127,6 +127,10 @@ func (m *Message) SetAddressHeader(field, address, name string) {
|
|||
|
||||
// FormatAddress formats an address and a name as a valid RFC 5322 address.
|
||||
func (m *Message) FormatAddress(address, name string) string {
|
||||
if name == "" {
|
||||
return address
|
||||
}
|
||||
|
||||
enc := m.encodeString(name)
|
||||
if enc == name {
|
||||
m.buf.WriteByte('"')
|
||||
|
|
|
@ -531,6 +531,18 @@ func TestBase64LineLength(t *testing.T) {
|
|||
testMessage(t, m, 0, want)
|
||||
}
|
||||
|
||||
func TestEmptyName(t *testing.T) {
|
||||
m := NewMessage()
|
||||
m.SetAddressHeader("From", "from@example.com", "")
|
||||
|
||||
want := &message{
|
||||
from: "from@example.com",
|
||||
content: "From: from@example.com\r\n",
|
||||
}
|
||||
|
||||
testMessage(t, m, 0, want)
|
||||
}
|
||||
|
||||
func TestEmptyHeader(t *testing.T) {
|
||||
m := NewMessage()
|
||||
m.SetHeaders(map[string][]string{
|
||||
|
|
Loading…
Reference in New Issue