mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 20:17:03 +01:00
Fix slice out of bounds error in mailer (#2479)
This commit is contained in:
parent
250f1236dc
commit
01d7189c2d
1 changed files with 2 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue