From 25b0e86730ed77f23faa81f4aff84d07a29652b6 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 4 Apr 2020 12:30:29 -0700 Subject: [PATCH] backup names don't actually matter all that much, they don't get used as file names --- .../Api/Client/Servers/Backups/StoreBackupRequest.php | 2 +- app/Models/Backup.php | 2 +- app/Services/Backups/InitiateBackupService.php | 3 +-- .../scripts/components/server/backups/CreateBackupButton.tsx | 4 +--- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php b/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php index 145cb4bb1..b5ef7110e 100644 --- a/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Backups/StoreBackupRequest.php @@ -21,7 +21,7 @@ class StoreBackupRequest extends ClientApiRequest public function rules(): array { return [ - 'name' => 'nullable|string|max:255|regex:/^[w\][\w\s_.-]*[\w]$/', + 'name' => 'nullable|string|max:255', 'ignore' => 'nullable|string', ]; } diff --git a/app/Models/Backup.php b/app/Models/Backup.php index 0bb181be9..56be90f87 100644 --- a/app/Models/Backup.php +++ b/app/Models/Backup.php @@ -65,7 +65,7 @@ class Backup extends Model public static $validationRules = [ 'server_id' => 'bail|required|numeric|exists:servers,id', 'uuid' => 'required|uuid', - 'name' => 'required|string|regex:/^[w\][\w\s_.-]*[\w]$/', + 'name' => 'required|string', 'ignored_files' => 'string', 'disk' => 'required|string', 'sha256_hash' => 'nullable|string', diff --git a/app/Services/Backups/InitiateBackupService.php b/app/Services/Backups/InitiateBackupService.php index 18b361ddf..82df733f0 100644 --- a/app/Services/Backups/InitiateBackupService.php +++ b/app/Services/Backups/InitiateBackupService.php @@ -4,7 +4,6 @@ namespace Pterodactyl\Services\Backups; use Ramsey\Uuid\Uuid; use Carbon\CarbonImmutable; -use Illuminate\Support\Str; use Pterodactyl\Models\Backup; use Pterodactyl\Models\Server; use Pterodactyl\Repositories\Eloquent\BackupRepository; @@ -59,7 +58,7 @@ class InitiateBackupService $backup = $this->repository->create([ 'server_id' => $server->id, 'uuid' => Uuid::uuid4()->toString(), - 'name' => Str::lower(str_replace(' ', '_', trim($name))) ?: sprintf('backup_%s', CarbonImmutable::create()->format('YmdHis')), + 'name' => trim($name) ?: sprintf('Backup at %s', CarbonImmutable::create()->toDateTimeString()), 'ignored_files' => $this->ignoredFiles ?? '', 'disk' => 'local', ], true, true); diff --git a/resources/scripts/components/server/backups/CreateBackupButton.tsx b/resources/scripts/components/server/backups/CreateBackupButton.tsx index c851bf922..889e14a07 100644 --- a/resources/scripts/components/server/backups/CreateBackupButton.tsx +++ b/resources/scripts/components/server/backups/CreateBackupButton.tsx @@ -96,9 +96,7 @@ export default ({ onBackupGenerated }: Props) => { onSubmit={submit} initialValues={{ name: '', ignored: '' }} validationSchema={object().shape({ - name: string().required() - .matches(/^[w\][\w\s_.-]*[\w]$/, 'Backup name must only contain alpha-numeric characters, spaces, underscores, dashes, and periods. The name must start and end with an alpha-numeric character.') - .max(255), + name: string().required().max(255), ignored: string(), })} >