From 3b109b96b27cf5e3cc5a25789a89253ad12673a9 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 6 Feb 2023 18:29:52 +0800 Subject: [PATCH] fix: cjk chars in filename --- web/Dockerfile | 2 +- web/app/controllers/problem_resources.php | 4 ++-- web/index.php | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/Dockerfile b/web/Dockerfile index e9f118a..f687802 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -6,7 +6,7 @@ ENV USE_MIRROR $USE_MIRROR SHELL ["/bin/bash", "-c"] ENV DEBIAN_FRONTEND=noninteractive -ENV PKGS="php7.4 php7.4-yaml php7.4-xml php7.4-dev php7.4-zip php7.4-mysql php7.4-mbstring php7.4-gd php7.4-curl php7.4-imagick libseccomp-dev git vim ntp zip unzip curl wget apache2 libapache2-mod-xsendfile php-pear mysql-client build-essential fp-compiler re2c libseccomp-dev libyaml-dev python2.7 python3.10 python3-requests openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk" +ENV PKGS="php7.4 php7.4-yaml php7.4-xml php7.4-dev php7.4-zip php7.4-mysql php7.4-mbstring php7.4-gd php7.4-curl php7.4-imagick libseccomp-dev git vim ntp zip unzip curl wget apache2 libapache2-mod-xsendfile php-pear mysql-client build-essential fp-compiler re2c libseccomp-dev libyaml-dev python2.7 python3.10 python3-requests openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk language-pack-zh*" RUN if [[ "$USE_MIRROR" == "1" ]]; then\ sed -i "s@http://.*archive.ubuntu.com@https://mirrors.aliyun.com@g" /etc/apt/sources.list &&\ sed -i "s@http://.*security.ubuntu.com@https://mirrors.aliyun.com@g" /etc/apt/sources.list ;\ diff --git a/web/app/controllers/problem_resources.php b/web/app/controllers/problem_resources.php index 474160f..00de3a8 100644 --- a/web/app/controllers/problem_resources.php +++ b/web/app/controllers/problem_resources.php @@ -37,10 +37,10 @@ define('FM_ROOT_URL', UOJProblem::cur()->getResourcesBaseUri()); $sub_path = UOJRequest::get('sub_path', 'is_string', ''); if ($sub_path) { - $filepath = realpath(UOJProblem::cur()->getResourcesPath($sub_path)); + $filepath = realpath(UOJProblem::cur()->getResourcesPath(rawurldecode($sub_path))); $realbasepath = realpath(UOJProblem::cur()->getResourcesPath()); - if (!str_starts_with($filepath, $realbasepath)) { + if (!strStartWith($filepath, $realbasepath)) { UOJResponse::page406(); } diff --git a/web/index.php b/web/index.php index 0953945..889a64d 100644 --- a/web/index.php +++ b/web/index.php @@ -1,5 +1,7 @@