Skip to content

Commit 41fa06b

Browse files
committed
Support user/password containing / and @
1 parent 3af0122 commit 41fa06b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/main/java/org/utplsql/cli/ConnectionConfig.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,26 @@ public class ConnectionConfig {
1010
private final String connect;
1111

1212
public ConnectionConfig( String connectString ) {
13-
Matcher m = Pattern.compile("^([^/]+)/([^@]+)@(.*)$").matcher(connectString);
13+
Matcher m = Pattern.compile("^(\".+\"|[^/]+)/(\".+\"|[^@]+)@(.*)$").matcher(connectString);
1414
if ( m.find() ) {
15-
user = m.group(1);
16-
password = m.group(2);
15+
user = stripEnclosingQuotes(m.group(1));
16+
password = stripEnclosingQuotes(m.group(2));
1717
connect = m.group(3);
1818
}
1919
else
2020
throw new IllegalArgumentException("Not a valid connectString: '" + connectString + "'");
2121
}
2222

23+
private String stripEnclosingQuotes( String value ) {
24+
if ( value.length() > 1
25+
&& value.startsWith("\"")
26+
&& value.endsWith("\"")) {
27+
return value.substring(1, value.length()-1);
28+
} else {
29+
return value;
30+
}
31+
}
32+
2333
public String getConnect() {
2434
return connect;
2535
}

0 commit comments

Comments
 (0)