From b939e9e3b42a60c6d107c7d8e2fa46e87810e93b Mon Sep 17 00:00:00 2001 From: Junaid Ahamed Date: Thu, 12 Nov 2026 14:27:37 +0530 Subject: [PATCH] fix(utils): allow apostrophes in person names --- packages/utils/package.json | 6 +- packages/utils/src/validation.test.ts | 82 +++++++++++++++++++++++++++ packages/utils/src/validation.ts | 5 +- pnpm-lock.yaml | 4 ++ 4 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 packages/utils/src/validation.test.ts diff --git a/packages/utils/package.json b/packages/utils/package.json index b65214a659c2..61f98e4eefef 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -20,7 +20,8 @@ "check:format": "oxfmt --check .", "fix:lint": "oxlint --fix .", "fix:format": "oxfmt .", - "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist" + "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist", + "test": "vitest run" }, "dependencies": { "@makeplane/propel": "catalog:", @@ -53,6 +54,7 @@ "@types/react": "catalog:", "@types/sanitize-html": "catalog:", "tsdown": "catalog:", - "typescript": "catalog:" + "typescript": "catalog:", + "vitest": "catalog:" } } diff --git a/packages/utils/src/validation.test.ts b/packages/utils/src/validation.test.ts new file mode 100644 index 000000000000..9866771fe8ac --- /dev/null +++ b/packages/utils/src/validation.test.ts @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2023-present Plane Software, Inc. and contributors + * SPDX-License-Identifier: AGPL-3.0-only + * See the LICENSE file for details. + */ + +import { describe, expect, it } from "vitest"; +import { + hasInjectionRiskChars, + validateCompanyName, + validateDisplayName, + validateOptionalPersonName, + validatePersonName, + validateSlug, + validateWorkspaceName, +} from "./validation"; + +describe("validatePersonName", () => { + it.each(["O'Brien", "D'Arcy", "Jean-Paul", "José", "李明", "محمد", " John ", "John\tPaul", "John\nPaul", "---"])( + "accepts names allowed by the existing pattern: %j", + (name) => { + expect(validatePersonName(name)).toBe(true); + expect(validateOptionalPersonName(name)).toBe(true); + } + ); + + it.each(["<", ">", '"', "{", "}", "[", "]", "*", "^", "!", "#", "%"])( + "still rejects %j when combined with an apostrophe", + (character) => { + const name = `O'Brien${character}`; + expect(validatePersonName(name)).toBe('Names cannot contain special characters like < > " { } [ ] * ^ ! # %'); + expect(validateOptionalPersonName(name)).not.toBe(true); + } + ); + + it.each([ + "O'Brien