From 25c9f7c0d9534dae386a5192749353e10fa96b26 Mon Sep 17 00:00:00 2001 From: bwcx_jzy Date: Thu, 13 Apr 2023 15:04:45 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=96=87=E4=BB=B6=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=90=8E=E7=BC=80=E8=AF=86=E5=88=AB=E6=94=AF=E6=8C=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E5=90=8D=E6=88=96=E8=80=85=E6=AD=A3?= =?UTF-8?q?=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG-BETA.md | 1 + .../jpom/model/data/AgentWhitelist.java | 27 +++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGELOG-BETA.md b/CHANGELOG-BETA.md index f8bf3691e..a7ebf1ef1 100644 --- a/CHANGELOG-BETA.md +++ b/CHANGELOG-BETA.md @@ -7,6 +7,7 @@ 1. 【server】优化 构建 SSH 发布命令支持 `SSH_RELEASE_PATH` 环境变量(感谢@定格) 2. 【server】修复 全屏终端无法打开文件管理(感谢@Pluto) 3. 【server】优化 自动探测服务端登录验证码是否可用 +4. 【all】优化 文件编辑后缀识别支持配置文件名或者正则表达式(感谢@MichelleChung) ------ diff --git a/modules/common/src/main/java/org/dromara/jpom/model/data/AgentWhitelist.java b/modules/common/src/main/java/org/dromara/jpom/model/data/AgentWhitelist.java index aa95773eb..8fe1076e4 100644 --- a/modules/common/src/main/java/org/dromara/jpom/model/data/AgentWhitelist.java +++ b/modules/common/src/main/java/org/dromara/jpom/model/data/AgentWhitelist.java @@ -27,6 +27,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.text.StrSplitter; import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; import lombok.Data; import lombok.EqualsAndHashCode; @@ -108,16 +109,16 @@ public class AgentWhitelist extends BaseJsonModel { return null; } return list.stream() - .map(s -> { - String val = String.format("/%s/", s); - val = FileUtil.normalize(val); - FileUtils.checkSlip(val); - // 判断是否保护jpom 路径 - Assert.state(!StrUtil.startWith(ExtConfigBean.getPath(), val), errorMsg); - return val; - }) - .distinct() - .collect(Collectors.toList()); + .map(s -> { + String val = String.format("/%s/", s); + val = FileUtil.normalize(val); + FileUtils.checkSlip(val); + // 判断是否保护jpom 路径 + Assert.state(!StrUtil.startWith(ExtConfigBean.getPath(), val), errorMsg); + return val; + }) + .distinct() + .collect(Collectors.toList()); } /** @@ -240,7 +241,11 @@ public class AgentWhitelist extends BaseJsonModel { } Set> entries = map.entrySet(); for (Map.Entry entry : entries) { - if (StrUtil.endWithIgnoreCase(filename, StrUtil.DOT + entry.getKey())) { + if (StrUtil.endWithAnyIgnoreCase(filename, entry.getKey(), StrUtil.DOT + entry.getKey())) { + return entry.getValue(); + } + if (ReUtil.isMatch(entry.getKey(), filename)) { + // 满足正则条件 return entry.getValue(); } }