Skip to content

Commit

Permalink
fix(contest/resources): send file as attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
renbaoshuo committed Nov 12, 2023
1 parent b0368c7 commit b23313b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion web/app/controllers/contest_resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
if ($sub_path) {
$filepath = realpath(UOJContest::cur()->getResourcesPath(rawurldecode($sub_path)));
$realbasepath = realpath(UOJContest::cur()->getResourcesPath());
$filename = basename($filepath);

if (!strStartWith($filepath, $realbasepath)) {
UOJResponse::page406();
}

UOJResponse::xsendfile($filepath);
UOJResponse::xsendfile($filepath, [
'attachment' => $filename,
]);
}

$global_readonly = !UOJContest::cur()->userCanManage(Auth::user());
Expand Down

0 comments on commit b23313b

Please sign in to comment.