Skip to content

Commit

Permalink
Be lenient as we can reasonably assume this is a ZIP file
Browse files Browse the repository at this point in the history
  • Loading branch information
vmcj committed Feb 24, 2024
1 parent 5a9c75e commit 106760c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion webapp/src/Service/ExternalContestSourceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1445,13 +1445,18 @@ protected function importSubmission(Event $event, EventData $data): void
'message' => 'No source files in event',
]);
$submissionDownloadSucceeded = false;
} elseif (($data->files[0]->mime ?? null) !== 'application/zip') {
} elseif (($data->files[0]->mime !== null && $data->files[0]->mime !== 'application/zip') {
$this->addOrUpdateWarning($event, $data->id, ExternalSourceWarning::TYPE_SUBMISSION_ERROR, [
'message' => 'Non-ZIP source files in event',
]);
$submissionDownloadSucceeded = false;
} else {
$zipUrl = $data->files[0]->href;
if (!isset($data['files'][0]['mime'])) {
$this->addOrUpdateWarning($eventId, $entityType, $data['id'], ExternalSourceWarning::TYPE_SUBMISSION_ERROR, [
'message' => 'MIME type not set, should be "application/zip"',
]);
}
if (preg_match('/^https?:\/\//', $zipUrl) === 0) {
// Relative URL, prepend the base URL.
$zipUrl = ($this->basePath ?? '') . $zipUrl;
Expand Down

0 comments on commit 106760c

Please sign in to comment.