mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-04 03:19:34 +00:00
fix(clients): reject spaces, '/', '\' and control chars in subscription ID
Like the client email, the subId is embedded directly in subscription URLs, so the same characters break it. Validate it on the backend (Create + Update) and the frontend (Zod), with a localized message across all 13 locales. An empty subId stays allowed (it is then auto-generated).
This commit is contained in:
@@ -119,7 +119,7 @@ export const GroupSummarySchema = z.object({
|
||||
|
||||
export const GroupSummaryListSchema = z.array(GroupSummarySchema).nullable().transform((v) => v ?? []);
|
||||
|
||||
export function emailHasForbiddenChars(value: string): boolean {
|
||||
export function hasForbiddenClientChars(value: string): boolean {
|
||||
if (value.includes('/') || value.includes('\\') || value.includes(' ')) return true;
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const code = value.charCodeAt(i);
|
||||
@@ -133,8 +133,8 @@ export const ClientFormSchema = z.object({
|
||||
.string()
|
||||
.trim()
|
||||
.min(1, 'pages.clients.email')
|
||||
.refine((v) => !emailHasForbiddenChars(v), 'pages.clients.emailInvalidChars'),
|
||||
subId: z.string(),
|
||||
.refine((v) => !hasForbiddenClientChars(v), 'pages.clients.emailInvalidChars'),
|
||||
subId: z.string().refine((v) => !hasForbiddenClientChars(v), 'pages.clients.subIdInvalidChars'),
|
||||
uuid: z.string(),
|
||||
password: z.string(),
|
||||
auth: z.string(),
|
||||
|
||||
Reference in New Issue
Block a user