This is an automated email from the ASF dual-hosted git repository.
Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 33e30336b4 fix: use come.google.re2j replace java.util.regex in
RegexPredicateJu… (#6410)
33e30336b4 is described below
commit 33e30336b4f03e27958289b1a417d4e8d413345b
Author: hengyuss <[email protected]>
AuthorDate: Tue Jul 7 18:21:44 2026 +0800
fix: use come.google.re2j replace java.util.regex in RegexPredicateJu…
(#6410)
* fix: use come.google.re2j replace java.util.regex in
RegexPredicateJudge.java and add URIConditionValidation in SelectorService
* fix: fix liscense
---
.../shenyu/admin/service/SelectorService.java | 7 +++++
.../src/main/release-docs/LICENSE | 1 +
.../main/release-docs/licenses/LICENSE-re2j.txt | 35 ++++++++++++++++++++++
.../src/main/release-docs/LICENSE | 2 +-
.../main/release-docs/licenses/LICENSE-re2j.txt | 35 ++++++++++++++++++++++
shenyu-plugin/shenyu-plugin-base/pom.xml | 4 +++
.../base/condition/judge/RegexPredicateJudge.java | 2 +-
7 files changed, 84 insertions(+), 2 deletions(-)
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/SelectorService.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/SelectorService.java
index a0934f5426..046789013f 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/SelectorService.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/SelectorService.java
@@ -27,7 +27,9 @@ import
org.apache.shenyu.admin.model.result.ConfigImportResult;
import org.apache.shenyu.admin.model.vo.SelectorVO;
import org.apache.shenyu.admin.service.configs.ConfigsImportContext;
import org.apache.shenyu.admin.utils.Assert;
+import org.apache.shenyu.admin.validation.validator.UriConditionValidator;
import org.apache.shenyu.common.dto.SelectorData;
+import org.apache.shenyu.common.enums.ParamTypeEnum;
import org.apache.shenyu.common.enums.SelectorTypeEnum;
import org.apache.shenyu.register.common.dto.MetaDataRegisterDTO;
@@ -71,6 +73,11 @@ public interface SelectorService extends
PageService<SelectorQueryCondition, Sel
Assert.notBlack(selectorConditionDTO.getParamType(), "if type
is custom, paramType is not empty");
Assert.notBlack(selectorConditionDTO.getParamName(), "if type
is custom, paramName is not empty");
});
+ selectorDTO.getSelectorConditions().stream()
+ .filter(conditionData ->
ParamTypeEnum.URI.getName().equals(conditionData.getParamType()))
+ .forEach(conditionData -> {
+
UriConditionValidator.validate(conditionData.getOperator(),
conditionData.getParamValue());
+ });
}
return StringUtils.isEmpty(selectorDTO.getId()) ? create(selectorDTO)
: update(selectorDTO);
}
diff --git a/shenyu-dist/shenyu-admin-dist/src/main/release-docs/LICENSE
b/shenyu-dist/shenyu-admin-dist/src/main/release-docs/LICENSE
index 51746ea72f..ab3eaef408 100644
--- a/shenyu-dist/shenyu-admin-dist/src/main/release-docs/LICENSE
+++ b/shenyu-dist/shenyu-admin-dist/src/main/release-docs/LICENSE
@@ -529,6 +529,7 @@ The text of each license is also included at
licenses/LICENSE-[project].txt.
stringtemplate 3.2.1: http://www.stringtemplate.org, BSD
xstream 1.4.19:
https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream, BSD
encoder 1.2.3: https://github.com/OWASP/owasp-java-encoder, BSD 3-Clause
+ re2j 1.8: https://github.com/google/re2j, BSD 3-Clause
========================================================================
CC0 licenses
diff --git
a/shenyu-dist/shenyu-admin-dist/src/main/release-docs/licenses/LICENSE-re2j.txt
b/shenyu-dist/shenyu-admin-dist/src/main/release-docs/licenses/LICENSE-re2j.txt
new file mode 100644
index 0000000000..3c75754584
--- /dev/null
+++
b/shenyu-dist/shenyu-admin-dist/src/main/release-docs/licenses/LICENSE-re2j.txt
@@ -0,0 +1,35 @@
+re2j License
+---------------
+
+This is a work derived from Russ Cox's RE2 in Go, whose license
+http://golang.org/LICENSE is as follows:
+
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ * Neither the name of Google Inc. nor the names of its contributors
+ may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
index a39f524a92..b9b01aa0f9 100644
--- a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
+++ b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/LICENSE
@@ -689,7 +689,7 @@ The text of each license is also included at
licenses/LICENSE-[project].txt.
asm-tree 9.2: https://asm.ow2.io/, BSD 3-Clause
polaris-all 1.13.0: https://github.com/polarismesh/polaris-java, BSD
3-Clause
re2j 1.6: https://github.com/google/re2j, BSD 3-Clause
- re2j 1.8: http://github.com/google/re2j, BSD 3-Clause
+ re2j 1.8: https://github.com/google/re2j, BSD 3-Clause
========================================================================
CC0 licenses
diff --git
a/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-re2j.txt
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-re2j.txt
new file mode 100644
index 0000000000..3c75754584
--- /dev/null
+++
b/shenyu-dist/shenyu-bootstrap-dist/src/main/release-docs/licenses/LICENSE-re2j.txt
@@ -0,0 +1,35 @@
+re2j License
+---------------
+
+This is a work derived from Russ Cox's RE2 in Go, whose license
+http://golang.org/LICENSE is as follows:
+
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ * Neither the name of Google Inc. nor the names of its contributors
+ may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/shenyu-plugin/shenyu-plugin-base/pom.xml
b/shenyu-plugin/shenyu-plugin-base/pom.xml
index ec9f557b66..e149863754 100644
--- a/shenyu-plugin/shenyu-plugin-base/pom.xml
+++ b/shenyu-plugin/shenyu-plugin-base/pom.xml
@@ -55,5 +55,9 @@
<artifactId>jackson-module-kotlin</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.google.re2j</groupId>
+ <artifactId>re2j</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git
a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/condition/judge/RegexPredicateJudge.java
b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/condition/judge/RegexPredicateJudge.java
index 370bdb56c9..6fc7e8476e 100644
---
a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/condition/judge/RegexPredicateJudge.java
+++
b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/condition/judge/RegexPredicateJudge.java
@@ -20,7 +20,7 @@ package org.apache.shenyu.plugin.base.condition.judge;
import org.apache.shenyu.common.dto.ConditionData;
import org.apache.shenyu.spi.Join;
-import java.util.regex.Pattern;
+import com.google.re2j.Pattern;
/**
* Regex predicate judge.