This commit is contained in:
looly 2021-11-20 17:08:28 +08:00
parent 60a8fd48f5
commit 490e512975
2 changed files with 12 additions and 2 deletions

View File

@ -3,7 +3,7 @@
-------------------------------------------------------------------------------------------------------------
# 5.7.17 (2021-11-19)
# 5.7.17 (2021-11-20)
### 🐣新特性
* 【core 】 增加AsyncUtilpr#457@Gitee
@ -24,6 +24,7 @@
### 🐞Bug修复
* 【core 】 修复FileResource构造fileName参数无效问题issue#1942@Github
* 【cache 】 修复WeakCache键值强关联导致的无法回收问题issue#1953@Github
* 【core 】 修复ZipUtil相对路径父路径获取null问题issue#1961@Github
-------------------------------------------------------------------------------------------------------------

View File

@ -1002,8 +1002,17 @@ public class ZipUtil {
throw new UtilException(StrUtil.format("File [{}] not exist!", srcFile.getAbsolutePath()));
}
// issue#1961@Github
// zipFile = new File("temp.zip") , zipFile.getParentFile() == null
File parentFile;
try {
parentFile = zipFile.getCanonicalFile().getParentFile();
} catch (IOException e) {
parentFile = zipFile.getParentFile();
}
// 压缩文件不能位于被压缩的目录内
if (srcFile.isDirectory() && FileUtil.isSub(srcFile, zipFile.getParentFile())) {
if (srcFile.isDirectory() && FileUtil.isSub(srcFile, parentFile)) {
throw new UtilException("Zip file path [{}] must not be the child directory of [{}] !", zipFile.getPath(), srcFile.getPath());
}
}