From 8ba9bd22e0ca9d6b831d1a58c220572b5f1adb01 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Tue, 29 Oct 2024 09:15:21 -0400 Subject: [PATCH] Allow Arabic and Cyrillic characters when signing up or creating community (#2780) * Allow Arabic and Cyrillic characters when signing up or creating community * Fix mistake with escape * Another escape mistake --- package.json | 2 +- src/shared/components/community/community-form.tsx | 3 ++- src/shared/components/home/signup.tsx | 4 ++-- src/shared/config.ts | 3 +++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1528f838..b32adab8 100644 --- a/package.json +++ b/package.json @@ -145,7 +145,7 @@ "sortpack" ] }, - "packageManager": "pnpm@9.12.2+sha512.22721b3a11f81661ae1ec68ce1a7b879425a1ca5b991c975b074ac220b187ce56c708fe5db69f4c962c989452eee76c82877f4ee80f474cebd61ee13461b6228", + "packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee", "engineStrict": true, "importSort": { ".js, .jsx, .ts, .tsx": { diff --git a/src/shared/components/community/community-form.tsx b/src/shared/components/community/community-form.tsx index 206fc841..49d402cc 100644 --- a/src/shared/components/community/community-form.tsx +++ b/src/shared/components/community/community-form.tsx @@ -14,6 +14,7 @@ import { ImageUploadForm } from "../common/image-upload-form"; import { LanguageSelect } from "../common/language-select"; import { MarkdownTextArea } from "../common/markdown-textarea"; import { tippyMixin } from "../mixins/tippy-mixin"; +import { validActorRegexPattern } from "../../config"; interface CommunityFormProps { community_view?: CommunityView; // If a community is given, that means this is an edit @@ -129,7 +130,7 @@ export class CommunityForm extends Component< onInput={linkEvent(this, this.handleCommunityNameChange)} required minLength={3} - pattern="[a-z0-9_]+" + pattern={validActorRegexPattern} title={I18NextService.i18n.t("community_reqs")} /> diff --git a/src/shared/components/home/signup.tsx b/src/shared/components/home/signup.tsx index 17361eea..2af157e6 100644 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@ -11,7 +11,7 @@ import { LoginResponse, SiteView, } from "lemmy-js-client"; -import { joinLemmyUrl } from "../../config"; +import { joinLemmyUrl, validActorRegexPattern } from "../../config"; import { mdToHtml } from "../../markdown"; import { I18NextService, UserService } from "../../services"; import { @@ -189,7 +189,7 @@ export class Signup extends Component { onInput={linkEvent(this, this.handleRegisterUsernameChange)} required minLength={3} - pattern="[a-zA-Z0-9_]+" + pattern={validActorRegexPattern} title={I18NextService.i18n.t("community_reqs")} /> diff --git a/src/shared/config.ts b/src/shared/config.ts index 38e26613..8418ee8e 100644 --- a/src/shared/config.ts +++ b/src/shared/config.ts @@ -50,3 +50,6 @@ export const instanceLinkRegex = new RegExp( ); export const testHost = "0.0.0.0:8536"; + +export const validActorRegexPattern = + "^\\w+|[\\p{Script=Arabic}\\d_]+|[\\p{Script=Cyrillic}\\d_]+$";