From 01d7189c2da827e2a7c793cffdc9166c35bc0507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=96stanb=C3=A4ck?= Date: Mon, 11 Sep 2017 08:33:28 +0200 Subject: [PATCH] Fix slice out of bounds error in mailer (#2479) --- modules/mailer/mailer.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go index 1f173e6b9..b941ccc31 100644 --- a/modules/mailer/mailer.go +++ b/modules/mailer/mailer.go @@ -16,6 +16,7 @@ import ( "strings" "time" + "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -41,7 +42,7 @@ func NewMessageFrom(to []string, from, subject, body string) *Message { plainBody, err := html2text.FromString(body) if err != nil || setting.MailService.SendAsPlainText { - if strings.Contains(body[:100], "") { + if strings.Contains(base.TruncateString(body, 100), ""){ log.Warn("Mail contains HTML but configured to send as plain text.") } msg.SetBody("text/plain", plainBody)