aboutsummaryrefslogtreecommitdiffstats
path: root/modules/mailer
diff options
context:
space:
mode:
authorJonas Östanbäck <cez81@users.noreply.github.com>2017-09-11 08:33:28 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2017-09-11 14:33:28 +0800
commit01d7189c2da827e2a7c793cffdc9166c35bc0507 (patch)
tree8bfaa70b14f482e07173369c6f3b6229fe8edb5e /modules/mailer
parent250f1236dc2455d5b5969f4bdc5ec0ab06ca81c0 (diff)
downloadgitea-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.go3
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)