From 24681c81c09022f584a57006f2534b5f74723414 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 30 六月 2026 09:27:31 +0800
Subject: [PATCH] 初始化项目
---
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/local/LocalFileClient.java | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/local/LocalFileClient.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/local/LocalFileClient.java
index 6e5c022..9c3af16 100644
--- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/local/LocalFileClient.java
+++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/local/LocalFileClient.java
@@ -3,8 +3,13 @@
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IORuntimeException;
import cn.iocoder.yudao.module.infra.framework.file.core.client.AbstractFileClient;
+import cn.iocoder.yudao.module.infra.framework.file.core.utils.FilePathUtils;
-import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_PATH_INVALID;
/**
* 鏈湴鏂囦欢瀹㈡埛绔�
@@ -50,7 +55,13 @@
}
private String getFilePath(String path) {
- return config.getBasePath() + File.separator + path;
+ FilePathUtils.validatePath(path);
+ Path basePath = Paths.get(config.getBasePath()).toAbsolutePath().normalize();
+ Path filePath = basePath.resolve(path).normalize();
+ if (!filePath.startsWith(basePath)) {
+ throw exception(FILE_PATH_INVALID);
+ }
+ return filePath.toString();
}
}
--
Gitblit v1.9.3