Skip to content

Commit 8e59bce

Browse files
committed
Escape database password to avoid parsing issue of SDN.
1 parent 4bcf1f4 commit 8e59bce

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/database/mariadb.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"fmt"
88
"log"
9+
"net/url"
910
"reflect"
1011
"strconv"
1112
"sync/atomic"
@@ -33,7 +34,7 @@ type SourceRelation struct {
3334

3435
// NewMariaDB create an instance of mariadb
3536
func NewMariaDB(username string, password string, host string, databaseName string, allowCleartextPassword bool) *MariaDB {
36-
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@(%s)/%s?allowCleartextPasswords=%s", username, password,
37+
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@(%s)/%s?allowCleartextPasswords=%s", username, url.QueryEscape(password),
3738
host, databaseName, strconv.FormatBool(allowCleartextPassword)))
3839
if err != nil {
3940
log.Fatal(err)

0 commit comments

Comments
 (0)