mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-23 02:50:39 +01:00
Add checks for nil or empty Subject headers
Added condition checks in `msg_test.go` for nil or empty Subject headers in the assigned functions. If the Subject is found to be nil or its length is less than 1, an empty string is now appended to prevent issues arising from null pointers or non-existent Subject headers in email messages.
This commit is contained in:
parent
81306e4dd3
commit
fd313e23b6
1 changed files with 6 additions and 0 deletions
|
@ -216,6 +216,9 @@ func (mw uppercaseMiddleware) Handle(m *Msg) *Msg {
|
|||
if !ok {
|
||||
fmt.Println("can't find the subject header")
|
||||
}
|
||||
if s == nil || len(s) < 1 {
|
||||
s = append(s, "")
|
||||
}
|
||||
m.Subject(strings.ToUpper(s[0]))
|
||||
return m
|
||||
}
|
||||
|
@ -231,6 +234,9 @@ func (mw encodeMiddleware) Handle(m *Msg) *Msg {
|
|||
if !ok {
|
||||
fmt.Println("can't find the subject header")
|
||||
}
|
||||
if s == nil || len(s) < 1 {
|
||||
s = append(s, "")
|
||||
}
|
||||
m.Subject(strings.Replace(s[0], "a", "@", -1))
|
||||
return m
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue