From 1ca805933f59ec57df661ca316c326481ea3c475 Mon Sep 17 00:00:00 2001 From: forgejo-backport-action Date: Fri, 16 May 2025 13:39:24 +0000 Subject: [PATCH] =?UTF-8?q?[v11.0/forgejo]=20fix:=20replace=20=C3=9F=20wit?= =?UTF-8?q?h=20ss=20in=20normalizeUserName=20(#7821)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Backport:** https://codeberg.org/forgejo/forgejo/pulls/7817 When using an oauth provider for login, we can't always make sure that only supported characters are included in the name. Therefore there exist normalization rules for the username. In German some names contain the `ß` letter which usually gets replaces by `ss`. Therfore I added this to the `customCharsReplacement` list. Without this fix, the user get's un undescriptive internal server error and the log states `CreateUser: name is invalid []: must be valid alpha or numeric or dash(-_) or dot characters`. Co-authored-by: Daniel Kilimnik Co-authored-by: Otto Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7821 Reviewed-by: Gusted Co-authored-by: forgejo-backport-action Co-committed-by: forgejo-backport-action --- models/user/user.go | 2 +- models/user/user_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/models/user/user.go b/models/user/user.go index fb43f01696..a0ee1e81b4 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -576,7 +576,7 @@ func GetUserSalt() (string, error) { // Note: The set of characters here can safely expand without a breaking change, // but characters removed from this set can cause user account linking to break var ( - customCharsReplacement = strings.NewReplacer("Æ", "AE") + customCharsReplacement = strings.NewReplacer("Æ", "AE", "ß", "ss") removeCharsRE = regexp.MustCompile(`['´\x60]`) removeDiacriticsTransform = transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC) replaceCharsHyphenRE = regexp.MustCompile(`[\s~+]`) diff --git a/models/user/user_test.go b/models/user/user_test.go index 63a12b788f..7c89337510 100644 --- a/models/user/user_test.go +++ b/models/user/user_test.go @@ -633,6 +633,7 @@ func Test_NormalizeUserFromEmail(t *testing.T) { {"test", "test", true}, {"Sinéad.O'Connor", "Sinead.OConnor", true}, {"Æsir", "AEsir", true}, + {"Flußpferd", "Flusspferd", true}, // \u00e9\u0065\u0301 {"éé", "ee", true}, {"Awareness Hub", "Awareness-Hub", true},