Skip to content

Commit

Permalink
Fix slice out of bounds error in mailer (#2479) (#2696)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored and lafriks committed Oct 13, 2017
1 parent ed07d8a commit 670562a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/mailer/mailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)
Expand Down

0 comments on commit 670562a

Please sign in to comment.