mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-09 15:32:54 +01:00
Protect against key not found in genHeader map in msg.go
Added checks to ensure the key HeaderMessageID exists in the genHeader map before attempting to operate on it in msg.go. This will prevent possible null pointer exceptions when trying to assign the key a value or append it to the mids slice.
This commit is contained in:
parent
da21550dc9
commit
5a4f814061
1 changed files with 6 additions and 2 deletions
|
@ -758,7 +758,9 @@ func TestMsg_SetMessageIDWithValue(t *testing.T) {
|
||||||
t.Errorf("SetMessageID() failed. Expected value, got: empty")
|
t.Errorf("SetMessageID() failed. Expected value, got: empty")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.genHeader[HeaderMessageID] = nil
|
if _, ok := m.genHeader[HeaderMessageID]; ok {
|
||||||
|
m.genHeader[HeaderMessageID] = nil
|
||||||
|
}
|
||||||
v := "This.is.a.message.id"
|
v := "This.is.a.message.id"
|
||||||
vf := "<This.is.a.message.id>"
|
vf := "<This.is.a.message.id>"
|
||||||
m.SetMessageIDWithValue(v)
|
m.SetMessageIDWithValue(v)
|
||||||
|
@ -779,7 +781,9 @@ func TestMsg_SetMessageIDRandomness(t *testing.T) {
|
||||||
m := NewMsg()
|
m := NewMsg()
|
||||||
m.SetMessageID()
|
m.SetMessageID()
|
||||||
mid := m.GetGenHeader(HeaderMessageID)
|
mid := m.GetGenHeader(HeaderMessageID)
|
||||||
mids = append(mids, mid[0])
|
if len(mid) > 0 {
|
||||||
|
mids = append(mids, mid[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c := make(map[string]int)
|
c := make(map[string]int)
|
||||||
for i := range mids {
|
for i := range mids {
|
||||||
|
|
Loading…
Reference in a new issue