Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): allow all unicode letters for signups (#12999)

Tobias Wochinger557f284cd122
diff --git a/web/src/__tests__/server/signup-schema-unicode-name.servertest.ts b/web/src/__tests__/server/signup-schema-unicode-name.servertest.ts
new file mode 100644
index 0000000000..e1fb64fbd9
--- /dev/null
+++ b/web/src/__tests__/server/signup-schema-unicode-name.servertest.ts
@@ -0,0 +1,138 @@
+import { signupSchema } from "@/src/features/auth/lib/signupSchema";
+
+describe("signupSchema name validation", () => {
+ const validBaseInput = {
+ email: "[email protected]",
+ password: "P@ssw0rd!",
+ };
+
+ it("accepts names with accented letters", () => {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: "André",
+ });
+
+ expect(result.success).toBe(true);
+ });
+
+ it("accepts names with hyphens", () => {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: "Smith-Jones",
+ });
+
+ expect(result.success).toBe(true);
+ });
+
+ it("accepts names with apostrophes", () => {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: "O'Brien",
+ });
+
+ expect(result.success).toBe(true);
+ });
+
+ it("accepts names with periods", () => {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: "Dr. Smith",
+ });
+
+ expect(result.success).toBe(true);
+ });
+
+ it("rejects names longer than 100 characters", () => {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: "a".repeat(101),
+ });
+
+ expect(result.success).toBe(false);
+ });
+
+ it("accepts names with smart/curly apostrophes (U+2019)", () => {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: "O\u2019Brien",
+ });
+
+ expect(result.success).toBe(true);
+ if (result.success) {
+ expect(result.data.name).toBe("O'Brien");
+ }
+ });
+
+ it("accepts names with left single quotation mark (U+2018)", () => {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: "O\u2018Brien",
+ });
+
+ expect(result.success).toBe(true);
+ if (result.success) {
+ expect(result.data.name).toBe("O'Brien");
+ }
+ });
+
+ it("rejects punctuation-only names", () => {
+ for (const name of ["---", "...", "'''"]) {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name,
+ });
+
+ expect(result.success).toBe(false);
+ }
+ });
+
+ it("rejects whitespace-only names", () => {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: " ",
+ });
+
+ expect(result.success).toBe(false);
+ });
+
+ it("rejects names with disallowed punctuation", () => {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: "André!",
+ });
+
+ expect(result.success).toBe(false);
+ });
+
+ it("rejects names with a leading combining mark", () => {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: "\u0301André",
+ });
+
+ expect(result.success).toBe(false);
+ });
+
+ it("rejects names consisting only of combining marks", () => {
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: "\u0301\u0302\u0303",
+ });
+
+ expect(result.success).toBe(false);
+ });
+
+ it("accepts NFD-decomposed names after NFC normalization", () => {
+ // "é" decomposed as e + combining acute accent
+ const result = signupSchema.safeParse({
+ ...validBaseInput,
+ name: "Andre\u0301",
+ });
+
+ expect(result.success).toBe(true);
+ if (result.success) {
+ // NFC normalization should merge the combining mark
+ expect(result.data.name).toBe("André");
+ }
+ });
+});
diff --git a/web/src/features/auth/lib/signupSchema.ts b/web/src/features/auth/lib/signupSchema.ts
index e43a167f49..749d33d4a9 100644
--- a/web/src/features/auth/lib/signupSchema.ts
+++ b/web/src/features/auth/lib/signupSchema.ts
@@ -17,12 +17,21 @@ export const passwordSchema = z
"Please choose a secure password by combining letters, numbers, and special characters.",
});
-export const signupSchema = z.object({
- name: StringNoHTMLNonEmpty.refine((value) => noUrlCheck(value), {
+export const nameSchema = StringNoHTMLNonEmpty.max(
+ 100,
+ "Name must be at most 100 characters",
+)
+ .transform((value) => value.normalize("NFC").replace(/[\u2018\u2019]/g, "'"))
+ .refine((value) => noUrlCheck(value), {
message: "Input should not contain a URL",
- }).refine((value) => /^[a-zA-Z0-9\s]+$/.test(value), {
- message: "Name can only contain letters, numbers, and spaces",
- }),
+ })
+ .refine((value) => /^\p{L}[\p{L}\p{M}\p{N}\s.'\-]*$/u.test(value), {
+ message:
+ "Name must start with a letter and can only contain letters, numbers, spaces, hyphens, apostrophes, and periods",
+ });
+
+export const signupSchema = z.object({
+ name: nameSchema,
email: z.string().email(),
password: passwordSchema,
referralSource: z.string().optional(),