From 378a0a92d92acdebadda1c36c3e83768f47853e3 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Thu, 7 Dec 2023 17:46:03 +0100 Subject: [PATCH] handle rules with `;;` correctly (this is the final one I swear) --- .../Controllers/Api/Client/Servers/StartupController.php | 3 ++- app/Services/Eggs/Variables/VariableCreationService.php | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/Client/Servers/StartupController.php b/app/Http/Controllers/Api/Client/Servers/StartupController.php index 9548be25e9..59d0cb5a78 100644 --- a/app/Http/Controllers/Api/Client/Servers/StartupController.php +++ b/app/Http/Controllers/Api/Client/Servers/StartupController.php @@ -2,6 +2,7 @@ namespace Pterodactyl\Http\Controllers\Api\Client\Servers; +use Illuminate\Support\Str; use Pterodactyl\Models\Server; use Pterodactyl\Facades\Activity; use Pterodactyl\Services\Servers\StartupCommandService; @@ -63,7 +64,7 @@ public function update(UpdateStartupVariableRequest $request, Server $server): a } // Revalidate the variable value using the egg variable specific validation rules for it. - $this->validate($request, ['value' => $variable->rules]); + $this->validate($request, ['value' => Str::contains($variable->rules, ';;') ? explode(';;', $variable->rules) : $variable->rules]); $this->repository->updateOrCreate([ 'server_id' => $server->id, diff --git a/app/Services/Eggs/Variables/VariableCreationService.php b/app/Services/Eggs/Variables/VariableCreationService.php index a7e19f6bac..10d9537eaf 100644 --- a/app/Services/Eggs/Variables/VariableCreationService.php +++ b/app/Services/Eggs/Variables/VariableCreationService.php @@ -2,6 +2,7 @@ namespace Pterodactyl\Services\Eggs\Variables; +use Illuminate\Support\Str; use Pterodactyl\Models\EggVariable; use Pterodactyl\Traits\Services\ValidatesValidationRules; use Illuminate\Contracts\Validation\Factory as ValidationFactory; @@ -42,7 +43,11 @@ public function handle(int $egg, array $data): EggVariable } if (!empty($data['rules'] ?? '')) { - $this->validateRules($data['rules']); + $this->validateRules( + (is_string($data['rules']) && Str::contains($data['rules'], ';;')) + ? explode(';;', $data['rules']) + : $data['rules'] + ); } $options = array_get($data, 'options') ?? [];