diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/BaseCondition.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/BaseCondition.java index 169d769389..321416d962 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/BaseCondition.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/BaseCondition.java @@ -23,13 +23,18 @@ public class BaseCondition { // 转JSON时会调用。 前台数据传过来时可以顺便处理掉转义字符 public void setKeyword(String keyword) { - keyword = StringUtils.replace(keyword, "%", "\\%"); - keyword = StringUtils.replace(keyword, "_", "\\_"); + //判断之前有没有转义过。转义过就不再转义。耍花活的自己想办法解决 + if (StringUtils.contains(keyword, "%") && !StringUtils.contains(keyword, "\\%")) { + keyword = StringUtils.replace(keyword, "%", "\\%"); + } + if (StringUtils.contains(keyword, "_") && !StringUtils.contains(keyword, "\\_")) { + keyword = StringUtils.replace(keyword, "_", "\\_"); + } this.keyword = keyword; } - // 直接初始化keyword public void initKeyword(String keyword) { + // 直接初始化keyword this.keyword = keyword; } }