diff --git a/dolphinscheduler-api/pom.xml b/dolphinscheduler-api/pom.xml
index 17306ba596..8646e31efc 100644
--- a/dolphinscheduler-api/pom.xml
+++ b/dolphinscheduler-api/pom.xml
@@ -216,6 +216,10 @@
org.apache.hadoop
hadoop-aws
+
+ org.hibernate.validator
+ hibernate-validator
+
org.codehaus.janino
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/CheckUtils.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/CheckUtils.java
index 0341e0b95d..3891087440 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/CheckUtils.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/CheckUtils.java
@@ -26,6 +26,7 @@ import org.apache.dolphinscheduler.common.utils.TaskParametersUtils;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.commons.lang.StringUtils;
+import org.hibernate.validator.internal.constraintvalidators.bv.EmailValidator;
import java.text.MessageFormat;
import java.util.HashMap;
@@ -59,11 +60,17 @@ public class CheckUtils {
* @return true if email regex valid, otherwise return false
*/
public static boolean checkEmail(String email) {
- if (StringUtils.isEmpty(email)) {
+ if (StringUtils.isBlank(email)) {
return false;
}
-
- return email.length() > 5 && email.length() <= 40 && regexChecks(email, Constants.REGEX_MAIL_NAME);
+ EmailValidator emailValidator = new EmailValidator();
+ if (!emailValidator.isValid(email, null)) {
+ return false;
+ }
+ //Email is at least a second-level domain name
+ int indexDomain = email.lastIndexOf("@");
+ String domainString = email.substring(indexDomain);
+ return domainString.contains(".");
}
/**
diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/CheckUtilsTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/CheckUtilsTest.java
index 71b0f929cd..e87e759b8e 100644
--- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/CheckUtilsTest.java
+++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/CheckUtilsTest.java
@@ -63,6 +63,8 @@ public class CheckUtilsTest {
public void testCheckEmail() {
assertTrue(CheckUtils.checkEmail("test01@gmail.com"));
assertFalse(CheckUtils.checkEmail("test01@gmail"));
+ assertFalse(CheckUtils.checkEmail("test01@gmail."));
+ assertTrue(CheckUtils.checkEmail("test01@gmail.edu.cn"));
}
/**
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
index 671af2bf26..d2b5952149 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
@@ -253,12 +253,7 @@ public final class Constants {
* user name regex
*/
public static final Pattern REGEX_USER_NAME = Pattern.compile("^[a-zA-Z0-9._-]{3,39}$");
-
- /**
- * email regex
- */
- public static final Pattern REGEX_MAIL_NAME = Pattern.compile("^([a-z0-9A-Z]+[_|\\-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");
-
+
/**
* read permission
*/
diff --git a/dolphinscheduler-dist/release-docs/LICENSE b/dolphinscheduler-dist/release-docs/LICENSE
index c989a964ee..cd605d7557 100644
--- a/dolphinscheduler-dist/release-docs/LICENSE
+++ b/dolphinscheduler-dist/release-docs/LICENSE
@@ -432,6 +432,9 @@ The text of each license is also included at licenses/LICENSE-[project].txt.
logging-interceptor 3.14.9 https://mvnrepository.com/artifact/com.squareup.okhttp3/logging-interceptor/3.14.9, Apache 2.0
okhttp 3.14.3 https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/3.14.3, Apache 2.0
okio 1.17.2 https://mvnrepository.com/artifact/com.squareup.okio/okio/1.17.2, Apache 2.0
+ hibernate-validator 6.2.2.Final https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator/6.2.2.Final, Apache 2.0
+ jakarta.validation-api 2.0.2 https://mvnrepository.com/artifact/jakarta.validation/jakarta.validation-api/2.0.2, Apache 2.0
+ jboss-logging:jar 3.4.2.Final https://mvnrepository.com/artifact/org.jboss.logging/jboss-logging/3.4.2.Final, Apache 2.0
========================================================================
BSD licenses
diff --git a/pom.xml b/pom.xml
index 9c0fc717b6..10c1fe35b6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,6 +128,7 @@
3.0.0
3.1.6
5.8.0
+ 6.2.2.Final
apache
${project.name}
@@ -923,6 +924,12 @@
kubernetes-client
${kubernetes.version}
+
+
+ org.hibernate.validator
+ hibernate-validator
+ ${hibernate.validator.version}
+
diff --git a/tools/dependencies/known-dependencies.txt b/tools/dependencies/known-dependencies.txt
index 8cf740278d..eba373d9f5 100755
--- a/tools/dependencies/known-dependencies.txt
+++ b/tools/dependencies/known-dependencies.txt
@@ -75,6 +75,7 @@ hadoop-yarn-api-2.7.3.jar
hadoop-yarn-client-2.7.3.jar
hadoop-yarn-common-2.7.3.jar
hadoop-yarn-server-common-2.7.3.jar
+hibernate-validator-6.2.2.Final.jar
hive-common-2.1.0.jar
hive-jdbc-2.1.0.jar
hive-metastore-2.1.0.jar
@@ -100,6 +101,7 @@ jackson-module-parameter-names-2.12.5.jar
jackson-xc-1.9.13.jar
jakarta.annotation-api-1.3.5.jar
jakarta.servlet-api-4.0.4.jar
+jakarta.validation-api-2.0.2.jar
jakarta.websocket-api-1.1.2.jar
jamon-runtime-2.3.1.jar
java-xmlbuilder-0.4.jar
@@ -112,6 +114,7 @@ javax.mail-1.6.2.jar
javolution-5.5.1.jar
jaxb-api-2.3.1.jar
jaxb-impl-2.2.3-1.jar
+jboss-logging-3.4.2.Final.jar
jdo-api-3.0.1.jar
jersey-client-1.9.jar
jersey-core-1.9.jar