From b0368c76c402301288263dd46c94a0358d4ac690 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 12 Nov 2023 15:46:42 +0800 Subject: [PATCH] fix(problem/resources): send files as attachment --- web/app/controllers/problem_resources.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/app/controllers/problem_resources.php b/web/app/controllers/problem_resources.php index 66eb9fa..432a516 100644 --- a/web/app/controllers/problem_resources.php +++ b/web/app/controllers/problem_resources.php @@ -35,12 +35,15 @@ $sub_path = UOJRequest::get('sub_path', 'is_string', ''); if ($sub_path) { $filepath = realpath(UOJProblem::cur()->getResourcesPath(rawurldecode($sub_path))); $realbasepath = realpath(UOJProblem::cur()->getResourcesPath()); + $filename = basename($filepath); if (!strStartWith($filepath, $realbasepath)) { UOJResponse::page406(); } - UOJResponse::xsendfile($filepath); + UOJResponse::xsendfile($filepath, [ + 'attachment' => $filename, + ]); } $global_readonly = !UOJProblem::cur()->userCanManage(Auth::user());