Commit 63612b88 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: validate time_control against allowed enum values (#schema-2)

Sanitize time_control to rapid_10_0 if not in the allowed list.
Prevents garbage values from reaching the database.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 6e27ece1
...@@ -83,6 +83,8 @@ function handleStart($db, string $userId, array $input): void { ...@@ -83,6 +83,8 @@ function handleStart($db, string $userId, array $input): void {
$gameKey = $input['game_key'] ?? 'chess'; $gameKey = $input['game_key'] ?? 'chess';
$mode = $input['mode'] ?? 'bot'; $mode = $input['mode'] ?? 'bot';
$timeControl = $input['time_control'] ?? 'rapid_10_0'; $timeControl = $input['time_control'] ?? 'rapid_10_0';
$validTimeControls = ['bullet_1_0','bullet_2_1','blitz_3_0','blitz_3_2','blitz_5_0','blitz_5_3','rapid_10_0','rapid_10_5','rapid_15_10','classical_30_0','classical_30_20','standard'];
if (!in_array($timeControl, $validTimeControls, true)) $timeControl = 'rapid_10_0';
$opponentId = $input['opponent_id'] ?? null; $opponentId = $input['opponent_id'] ?? null;
$botId = $input['bot_id'] ?? null; $botId = $input['bot_id'] ?? null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment