1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-03 00:45:22 +02:00

[v11.0/forgejo] fix: replace ß with ss in normalizeUserName (#7821)

**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 [<name>]: must be valid alpha or numeric or dash(-_) or dot characters`.

Co-authored-by: Daniel Kilimnik <daniel@neodyme.io>
Co-authored-by: Otto <otto@codeberg.org>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7821
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
This commit is contained in:
forgejo-backport-action 2025-05-16 13:39:24 +00:00 committed by Gusted
parent da267ab00e
commit 1ca805933f
2 changed files with 2 additions and 1 deletions

View file

@ -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~+]`)

View file

@ -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},