Skip to content

Commit

Permalink
Merge pull request #54 from lasanthaS/master
Browse files Browse the repository at this point in the history
Fix JDBC URLs to accept hostnames
  • Loading branch information
dnwick authored Mar 20, 2020
2 parents bf4ef2a + 9193e39 commit cd5c722
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public static Map<String, Object> getConfigMap(String username, String password,
switch (splittedURL[1]) {
case "mysql": {
//Extract url details
String regex = "jdbc:mysql://(\\w*|[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}):" +
"(\\d++)/(\\w*)";
String regex = "jdbc:mysql://([a-zA-Z0-9-_\\.]+):(\\d++)/(\\w*)";
Pattern p = Pattern.compile(regex);
Matcher matcher = p.matcher(url);
if (matcher.find()) {
Expand All @@ -77,8 +76,7 @@ public static Map<String, Object> getConfigMap(String username, String password,
}
case "postgresql": {
//Extract url details
String regex = "jdbc:postgresql://(\\w*|[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}):" +
"(\\d++)/(\\w*)";
String regex = "jdbc:postgresql://([a-zA-Z0-9-_\\.]+):(\\d++)/(\\w*)";
Pattern p = Pattern.compile(regex);
Matcher matcher = p.matcher(url);
if (matcher.find()) {
Expand All @@ -103,8 +101,7 @@ public static Map<String, Object> getConfigMap(String username, String password,
}
case "sqlserver": {
//Extract url details
String regex = "jdbc:sqlserver://(\\w*|[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}):" +
"(\\d++);databaseName=(\\w*)";
String regex = "jdbc:sqlserver://([a-zA-Z0-9-_\\.]+):(\\d++);databaseName=(\\w*)";
Pattern p = Pattern.compile(regex);
Matcher matcher = p.matcher(url);
if (matcher.find()) {
Expand Down Expand Up @@ -162,8 +159,7 @@ public static Map<String, Object> getConfigMap(String username, String password,
case "mongodb": {
//Extract url details
isMongodb = true;
String regex = "jdbc:mongodb://(\\w*|(\\w*)/[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}):" +
"(\\d++)/(\\w*)";
String regex = "jdbc:mongodb://(\\w*|(\\w*)/[a-zA-Z0-9-_\\.]+):(\\d++)/(\\w*)";
Pattern p = Pattern.compile(regex);
Matcher matcher = p.matcher(url);
String replicaSetName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void cdcUrlValidation() throws InterruptedException {

SiddhiManager siddhiManager = new SiddhiManager();

String wrongURL = "jdbc:mysql://0.0.0.0.0:3306/SimpleDB";
String wrongURL = "jdbc:mysql://0.0.0.0:3306abc/SimpleDB";

//stream definition with invalid operation.
String inStreamDefinition = "" +
Expand Down

0 comments on commit cd5c722

Please sign in to comment.