Skip to content

Commit f668c07

Browse files
committed
Only import valid RGB values when shadowing
The contest validation breaks when the contestproblem has an invalid color PC^2 doesn't check the colors as they don't need them so mistakes in the problemset.yaml would also be fed to the feed.
1 parent 5c04267 commit f668c07

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

webapp/src/Service/ExternalContestSourceService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,12 @@ protected function validateAndUpdateProblem(Event $event, EventData $data): void
10501050
);
10511051
$contestProblem->setShortname($data->label);
10521052
}
1053-
if ($contestProblem->getColor() !== ($data->rgb)) {
1053+
if (preg_match('/^#[[:xdigit:]]{3}(?:[[:xdigit:]]{3}){0,2}$/', $data->rgb)) {
1054+
$this->logger->warning(
1055+
'Contest problem color does not match between feed (%s) and local (%s), but feed is invalid.',
1056+
[$data->rgb, $contestProblem->getColor()]
1057+
);
1058+
} elseif ($contestProblem->getColor() !== ($data->rgb)) {
10541059
$this->logger->warning(
10551060
'Contest problem color does not match between feed (%s) and local (%s), updating',
10561061
[$data->rgb, $contestProblem->getColor()]

0 commit comments

Comments
 (0)