mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-19 12:56:10 +02:00
fix(user): don't match a commit with an empty author email to a user (#39777)
Fixes https://github.com/go-gitea/gitea/issues/39776
This commit is contained in:
1 parent
ccc9b928fe
commit
76f8dc38e7
2 files changed
+9
No files matched your search
@@ -1231,6 +1231,9 @@ func GetUsersByEmails(ctx context.Context, emails []string) (*EmailUserMap, erro
|
||||
noReplyAddressSuffix := "@" + strings.ToLower(setting.Service.NoReplyAddress)
|
||||
for _, email := range emails {
|
||||
emailLower := strings.ToLower(email)
|
||||
if emailLower == "" {
|
||||
continue // a commit without an author email names no user
|
||||
}
|
||||
needCheckEmails.Add(emailLower)
|
||||
if localPart, ok := strings.CutSuffix(emailLower, noReplyAddressSuffix); ok {
|
||||
name, id := parseLocalPartToNameID(localPart)
|
||||
|
||||
@@ -96,6 +96,12 @@ func TestUserEmails(t *testing.T) {
|
||||
setting.Service.NoReplyAddress = "example.com"
|
||||
testGetUserByEmail(t, "user1-2@example.COM", 1)
|
||||
})
|
||||
|
||||
t.Run("EmptyEmail", func(t *testing.T) {
|
||||
// A user whose email address is empty must not own commits that have no author email.
|
||||
require.NoError(t, db.Insert(t.Context(), &user_model.EmailAddress{UID: 2, Email: "", LowerEmail: "", IsActivated: true}))
|
||||
testGetUserByEmail(t, "", 0)
|
||||
})
|
||||
})
|
||||
t.Run("GetUserByEmail", func(t *testing.T) {
|
||||
testGetUserByEmail := func(t *testing.T, email string, uid int64) {
|
||||
|
||||
Reference in new issue
Block a user