mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +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")
|
||||
return
|
||||
}
|
||||
if _, ok := m.genHeader[HeaderMessageID]; ok {
|
||||
m.genHeader[HeaderMessageID] = nil
|
||||
}
|
||||
v := "This.is.a.message.id"
|
||||
vf := "<This.is.a.message.id>"
|
||||
m.SetMessageIDWithValue(v)
|
||||
|
@ -779,8 +781,10 @@ func TestMsg_SetMessageIDRandomness(t *testing.T) {
|
|||
m := NewMsg()
|
||||
m.SetMessageID()
|
||||
mid := m.GetGenHeader(HeaderMessageID)
|
||||
if len(mid) > 0 {
|
||||
mids = append(mids, mid[0])
|
||||
}
|
||||
}
|
||||
c := make(map[string]int)
|
||||
for i := range mids {
|
||||
c[mids[i]]++
|
||||
|
|
Loading…
Reference in a new issue