From b23313bd4fba1b398ed75caf37bdc8def1a9dc72 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 12 Nov 2023 15:46:48 +0800 Subject: [PATCH] fix(contest/resources): send file as attachment --- web/app/controllers/contest_resources.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/app/controllers/contest_resources.php b/web/app/controllers/contest_resources.php index 710fbf8..66fbb81 100644 --- a/web/app/controllers/contest_resources.php +++ b/web/app/controllers/contest_resources.php @@ -19,12 +19,15 @@ $sub_path = UOJRequest::get('sub_path', 'is_string', ''); 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());