From 94c00312c1e9bb7c84ace21c4bf343e819489014 Mon Sep 17 00:00:00 2001 From: HarikrishnanD Date: Thu, 30 Oct 2025 12:54:37 +0530 Subject: [PATCH] feat(volumes): reject spaces/quotes in volume names per Docker rules (#2916) --- .../application/advanced/volumes/add-volumes.tsx | 8 +++++++- .../application/advanced/volumes/update-volume.tsx | 8 +++++++- .../application/volume-backups/handle-volume-backups.tsx | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/advanced/volumes/add-volumes.tsx b/apps/dokploy/components/dashboard/application/advanced/volumes/add-volumes.tsx index d7621bc1e..2bfd6bbc0 100644 --- a/apps/dokploy/components/dashboard/application/advanced/volumes/add-volumes.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/volumes/add-volumes.tsx @@ -59,7 +59,13 @@ const mySchema = z.discriminatedUnion("type", [ z .object({ type: z.literal("volume"), - volumeName: z.string().min(1, "Volume name required"), + volumeName: z + .string() + .min(1, "Volume name required") + .regex( + /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/, + "Invalid volume name. Use letters, numbers, '._-' and start with a letter/number.", + ), }) .merge(mountSchema), z diff --git a/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx b/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx index 38d02ec90..44fb050bc 100644 --- a/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/volumes/update-volume.tsx @@ -41,7 +41,13 @@ const mySchema = z.discriminatedUnion("type", [ z .object({ type: z.literal("volume"), - volumeName: z.string().min(1, "Volume name required"), + volumeName: z + .string() + .min(1, "Volume name required") + .regex( + /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/, + "Invalid volume name. Use letters, numbers, '._-' and start with a letter/number.", + ), }) .merge(mountSchema), z diff --git a/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx b/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx index 804b4c39b..e179713de 100644 --- a/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx +++ b/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx @@ -47,7 +47,13 @@ const formSchema = z .object({ name: z.string().min(1, "Name is required"), cronExpression: z.string().min(1, "Cron expression is required"), - volumeName: z.string().min(1, "Volume name is required"), + volumeName: z + .string() + .min(1, "Volume name is required") + .regex( + /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/, + "Invalid volume name. Use letters, numbers, '._-' and start with a letter/number.", + ), prefix: z.string(), keepLatestCount: z.coerce .number()