From 1a46bc96f9d6f8538d56bc2b2e0039a12c72c5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=96stanb=C3=A4ck?= Date: Sun, 10 Sep 2017 09:04:08 +0200 Subject: [PATCH] Fix slice out of bounds error in mailer --- 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 1f173e6b9098..b941ccc31f6a 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)