fix: treat email addresses case-insensitively (#37600) (#37611)

This commit is contained in:
Giteabot
2026-05-08 11:32:25 -07:00
committed by GitHub
parent b28c4f2b08
commit 65f3feaa84
7 changed files with 72 additions and 71 deletions
+14
View File
@@ -7,6 +7,8 @@ import (
"strings"
"testing"
"code.gitea.io/gitea/modules/setting"
"github.com/jhillyerd/enmime/v2"
"github.com/stretchr/testify/assert"
)
@@ -68,6 +70,18 @@ func TestIsAutomaticReply(t *testing.T) {
}
}
func TestSearchTokenInHeadersCaseInsensitive(t *testing.T) {
setting.IncomingEmail.ReplyToAddress = "InComing+%{token}@ExAmPle.com"
setting.Domain = "DoMain.com"
mkEnv := func(s string) *enmime.Envelope {
env, _ := enmime.ReadEnvelope(strings.NewReader(s + "\r\n\r\n"))
return env
}
assert.Equal(t, "abc", searchTokenInHeaders(mkEnv("To: incoming+abc@EXAMPLE.COM")))
assert.Equal(t, "abc", searchTokenInHeaders(mkEnv("Delivered-To: INCOMING+abc@example.com")))
assert.Equal(t, "abc", searchTokenInHeaders(mkEnv("References: <ReplY-abc@DomaiN.COM>")))
}
func TestGetContentFromMailReader(t *testing.T) {
mailString := "Content-Type: multipart/mixed; boundary=message-boundary\r\n" +
"\r\n" +