diff options
author | Jonas Östanbäck <cez81@users.noreply.github.com> | 2017-09-11 08:33:28 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-09-11 14:33:28 +0800 |
commit | 01d7189c2da827e2a7c793cffdc9166c35bc0507 (patch) | |
tree | 8bfaa70b14f482e07173369c6f3b6229fe8edb5e /modules/mailer | |
parent | 250f1236dc2455d5b5969f4bdc5ec0ab06ca81c0 (diff) | |
download | gitea-01d7189c2da827e2a7c793cffdc9166c35bc0507.tar.gz gitea-01d7189c2da827e2a7c793cffdc9166c35bc0507.zip |
Fix slice out of bounds error in mailer (#2479)
Diffstat (limited to 'modules/mailer')
-rw-r--r-- | modules/mailer/mailer.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go index 1f173e6b90..b941ccc31f 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], "<html>") { + if strings.Contains(base.TruncateString(body, 100), "<html>"){ log.Warn("Mail contains HTML but configured to send as plain text.") } msg.SetBody("text/plain", plainBody) |