mirror of
https://github.com/element-hq/matrix-authentication-service.git
synced 2026-10-23 02:13:37 +00:00
Lowercase usernames without the browser locale
`toLocaleLowerCase()` follows the browser locale, so with a Turkish locale `I` became a dotless `ı`, which is not a valid localpart and does not match what the server does with `to_lowercase`.
This commit is contained in:
1 parent
7232057685
commit
5a649f0424
3 files changed
+5
-4
No files matched your search
@@ -36,7 +36,7 @@ export const UsernameField: React.FC<{
|
||||
value={username}
|
||||
onChange={(e) => {
|
||||
// Lowercase as the user types, so what is shown is what gets sent
|
||||
setUsername(e.target.value.toLocaleLowerCase());
|
||||
setUsername(e.target.value.toLowerCase());
|
||||
}}
|
||||
onBlur={() => setUsername(normalizeUsername(username))}
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Copyright 2025 New Vector Ltd.
|
||||
/* Copyright 2025, 2026 Element Creations Ltd.
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
@@ -66,7 +67,7 @@ function patchUsernameInput(inputElement: HTMLInputElement) {
|
||||
|
||||
inputElement.addEventListener("input", () => {
|
||||
// Simply lowercase things automatically, as this is not too disruptive
|
||||
inputElement.value = inputElement.value.toLocaleLowerCase();
|
||||
inputElement.value = inputElement.value.toLowerCase();
|
||||
|
||||
const match = inputElement.value.match(VALID_USERNAME_RE);
|
||||
if (!inputElement.value.trim() || match !== null) {
|
||||
|
||||
@@ -37,7 +37,7 @@ export const VALID_LOCALPART_RE = /^[a-z0-9._=/+-]+$/;
|
||||
|
||||
/** Normalize a username: trim and lowercase. */
|
||||
export const normalizeUsername = (value: string): string =>
|
||||
value.trim().toLocaleLowerCase();
|
||||
value.trim().toLowerCase();
|
||||
|
||||
/**
|
||||
* Well-known policy violation codes, mapped to the key of their translated
|
||||
|
||||
Reference in new issue
Block a user