Skip to content

Commit 670562a

Browse files
lunnylafriks
authored andcommitted
Fix slice out of bounds error in mailer (#2479) (#2696)
1 parent ed07d8a commit 670562a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/mailer/mailer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"strings"
1717
"time"
1818

19+
"code.gitea.io/gitea/modules/base"
1920
"code.gitea.io/gitea/modules/log"
2021
"code.gitea.io/gitea/modules/setting"
2122

@@ -41,7 +42,7 @@ func NewMessageFrom(to []string, from, subject, body string) *Message {
4142

4243
plainBody, err := html2text.FromString(body)
4344
if err != nil || setting.MailService.SendAsPlainText {
44-
if strings.Contains(body[:100], "<html>") {
45+
if strings.Contains(base.TruncateString(body, 100), "<html>") {
4546
log.Warn("Mail contains HTML but configured to send as plain text.")
4647
}
4748
msg.SetBody("text/plain", plainBody)

0 commit comments

Comments
 (0)