Skip to content

Commit 6ae92b2

Browse files
Drop double / between base path and relative URL's.
1 parent b4cdfbe commit 6ae92b2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

webapp/src/Service/ExternalContestSourceService.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,9 +1450,12 @@ protected function importSubmission(Event $event, EventData $data): void
14501450
$zipUrl = $data->files[0]->href;
14511451
if (preg_match('/^https?:\/\//', $zipUrl) === 0) {
14521452
// Relative URL, prepend the base URL.
1453+
// If both the base path ends with a / and the zip URL starts with one, drop one of them
1454+
if (str_ends_with($this->basePath, '/') && str_starts_with($zipUrl, '/')) {
1455+
$zipUrl = substr($zipUrl, 1);
1456+
}
14531457
$zipUrl = ($this->basePath ?? '') . $zipUrl;
14541458
}
1455-
$zipUrl = str_replace('//', '/', $zipUrl);
14561459

14571460
$tmpdir = $this->dj->getDomjudgeTmpDir();
14581461

0 commit comments

Comments
 (0)