From a1465cc8269e2ecf77cbc0fc508b685ba1ecf29c Mon Sep 17 00:00:00 2001 From: Kirs Date: Mon, 19 Jul 2021 16:30:07 +0800 Subject: [PATCH] [1.3.7-prepare#5737][Datasource] datsource other param check error (#5838) --- .../dolphinscheduler/api/service/DataSourceService.java | 2 +- .../api/service/DataSourceServiceTest.java | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java index 38ffee0933..c3456e247e 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java @@ -80,7 +80,7 @@ public class DataSourceService extends BaseService{ private static final Pattern DATABASE_PATTER = Pattern.compile("^[a-zA-Z0-9\\_\\-\\.]+$"); - private static final Pattern PARAMS_PATTER = Pattern.compile("^[a-zA-Z0-9]+$"); + private static final Pattern PARAMS_PATTER = Pattern.compile("^[a-zA-Z0-9\\-\\_\\/]+$"); @Autowired diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java index 070160de0a..367499a952 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java @@ -102,18 +102,16 @@ public class DataSourceServiceTest { @Test public void buildParameterWithDecodePassword() { PropertyUtils.setValue(Constants.DATASOURCE_ENCRYPTION_ENABLE, "true"); - String other = "{\"autoDeserialize\":\"yes\",\"allowUrlInLocalInfile\":\"true\"}"; + String other = "{\"autoDeserialize\":\"yes\",\"allowUrlInLocalInfile\":\"true\",\"serverTimezone\":\"Asia/Shanghai\",\"queryTimeout\":\"-1\",\"characterEncoding\":\"utf8\"}"; String param = dataSourceService.buildParameter("root","test",DbType.MYSQL, "192.168.9.1", "1521", "im" , "", "test", "123456", null, other); - String expected = "{\"address\":\"jdbc:mysql://192.168.9.1:1521\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:mysql://192.168.9.1:1521/im\"," - + "\"user\":\"test\",\"password\":\"123456\"}"; + String expected = "{\"address\":\"jdbc:mysql://192.168.9.1:1521\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:mysql://192.168.9.1:1521/im\",\"user\":\"test\",\"password\":\"123456\",\"other\":\"serverTimezone=Asia/Shanghai&queryTimeout=-1&characterEncoding=utf8\"}"; Assert.assertEquals(expected, param); PropertyUtils.setValue(Constants.DATASOURCE_ENCRYPTION_ENABLE, "false"); param = dataSourceService.buildParameter("root","test",DbType.MYSQL, "192.168.9.1", "1521", "im" , "", "test", "123456", null, other); - expected = "{\"address\":\"jdbc:mysql://192.168.9.1:1521\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:mysql://192.168.9.1:1521/im\"," - + "\"user\":\"test\",\"password\":\"123456\"}"; + expected = "{\"address\":\"jdbc:mysql://192.168.9.1:1521\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:mysql://192.168.9.1:1521/im\",\"user\":\"test\",\"password\":\"123456\",\"other\":\"serverTimezone=Asia/Shanghai&queryTimeout=-1&characterEncoding=utf8\"}"; Assert.assertEquals(expected, param); }