Skip to content

Commit

Permalink
handle rules with ;; correctly
Browse files Browse the repository at this point in the history
(this is the final one I swear)
  • Loading branch information
Boy132 committed Dec 7, 2023
1 parent fdf6e67 commit 378a0a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion app/Services/Eggs/Variables/VariableCreationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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') ?? [];
Expand Down

0 comments on commit 378a0a9

Please sign in to comment.