Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Support user/password containing / and @
  • Loading branch information
pesse committed Mar 15, 2019
commit 41fa06b532a1770fc9ec7d5e070198540de78619
16 changes: 13 additions & 3 deletions src/main/java/org/utplsql/cli/ConnectionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,26 @@ public class ConnectionConfig {
private final String connect;

public ConnectionConfig( String connectString ) {
Matcher m = Pattern.compile("^([^/]+)/([^@]+)@(.*)$").matcher(connectString);
Matcher m = Pattern.compile("^(\".+\"|[^/]+)/(\".+\"|[^@]+)@(.*)$").matcher(connectString);
if ( m.find() ) {
user = m.group(1);
password = m.group(2);
user = stripEnclosingQuotes(m.group(1));
password = stripEnclosingQuotes(m.group(2));
connect = m.group(3);
}
else
throw new IllegalArgumentException("Not a valid connectString: '" + connectString + "'");
}

private String stripEnclosingQuotes( String value ) {
if ( value.length() > 1
&& value.startsWith("\"")
&& value.endsWith("\"")) {
return value.substring(1, value.length()-1);
} else {
return value;
}
}

public String getConnect() {
return connect;
}
Expand Down