From c535fd869b2df6f7f094e330acab9a9d610be173 Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Thu, 10 Apr 2025 11:19:06 +0100 Subject: [PATCH] Validate that time property is valid and not in the future --- validator.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/validator.php b/validator.php index d38968793..24e3f3c92 100644 --- a/validator.php +++ b/validator.php @@ -177,6 +177,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!array_key_exists('time', $branch)) { $messages[$path][] = sprintf('Key "time" is required for branch "%s".', $name); + } elseif (isset($branch['time'])) { + $timestamp = is_int($branch['time']) ? $branch['time'] : strtotime($branch['time']); + + if ($timestamp === false) { + $messages[$path][] = sprintf('"time" is invalid for branch "%s", given "%s".', $name, $branch['time']); + } elseif ($timestamp > time()) { + $messages[$path][] = sprintf('"time" cannot be in the future for branch "%s", given "%s".', $name, $branch['time']); + } } if (!isset($branch['versions'])) {