Skip to content

Commit b6a59c6

Browse files
remove escaping for mySQL
1 parent ec8e377 commit b6a59c6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

internal/sqlquery/scraper.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,12 @@ func buildPostgreSQLString(conn DataSourceConfig) (string, error) {
149149
func buildMySQLString(conn DataSourceConfig) (string, error) {
150150
// MySQL connection string format: user:pass@tcp(host:port)/db?param1=value1&param2=value2
151151
var auth string
152+
153+
// MySQL requires no escaping of username and password
152154
if conn.Username != "" {
153-
auth = fmt.Sprintf("%s:%s@", url.QueryEscape(conn.Username), url.QueryEscape(string(conn.Password)))
155+
username := conn.Username
156+
password := string(conn.Password)
157+
auth = fmt.Sprintf("%s:%s@", username, password)
154158
}
155159

156160
query := url.Values{}

internal/sqlquery/scraper_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,15 +703,15 @@ func TestBpConnectionStringBuilder(t *testing.T) {
703703
expected: "postgresql://user%40domain:pass%23word%40123@localhost:5432/mydb?app=my%23app&sslmode=disable",
704704
},
705705
{
706-
name: "mysql with invalid username and password",
706+
name: "mysql with invalid username and password, no escaping",
707707
driver: "mysql",
708708
host: "localhost",
709709
port: 3306,
710710
database: "mydb",
711711
username: "user@domain+",
712712
password: "pass#word@123",
713713
queryParams: map[string]any{"sslmode": "disable", "app": "my#app"},
714-
expected: "user%40domain%2B:pass%23word%40123@tcp(localhost:3306)/mydb?app=my%23app&sslmode=disable",
714+
expected: "user@domain+:pass#word@123@tcp(localhost:3306)/mydb?app=my%23app&sslmode=disable",
715715
},
716716
{
717717
name: "snowflake with invalid username and password",

0 commit comments

Comments
 (0)