Skip to content

Commit

Permalink
Remove password from db.user parsed from JDBC url (#8106)
Browse files Browse the repository at this point in the history
Resolves
#8105
  • Loading branch information
laurit committed Mar 22, 2023
1 parent aa2b853 commit 0a311a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) {

String user = uri.getUserInfo();
if (user != null) {
int colonIndex = user.indexOf(':');
if (colonIndex != -1) {
user = user.substring(0, colonIndex);
}
builder.user(user);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class JdbcConnectionUrlParserTest extends Specification {
"jdbc:mysql:https://my.host?user=myuser&password=PW" | null | "mysql:https://my.host:3306" | "mysql" | null | "myuser" | "my.host" | 3306 | null | null
"jdbc:mysql:https://my.host:22/mydb?user=myuser&password=PW" | null | "mysql:https://my.host:22" | "mysql" | null | "myuser" | "my.host" | 22 | null | "mydb"
"jdbc:mysql:https://127.0.0.1:22/mydb?user=myuser&password=PW" | stdProps | "mysql:https://127.0.0.1:22" | "mysql" | null | "myuser" | "127.0.0.1" | 22 | null | "mydb"
"jdbc:mysql:https://myuser:[email protected]:22/mydb" | null | "mysql:https://my.host:22" | "mysql" | null | "myuser" | "my.host" | 22 | null | "mydb"

// https://mariadb.com/kb/en/library/about-mariadb-connector-j/#connection-strings
"jdbc:mariadb:127.0.0.1:33/mdbdb" | null | "mariadb:https://127.0.0.1:33" | "mariadb" | null | null | "127.0.0.1" | 33 | null | "mdbdb"
Expand Down

0 comments on commit 0a311a1

Please sign in to comment.