Skip to content

Commit 8960223

Browse files
authored
Support @ in the password of dsn (#66)
* support @ in the password of dsn * support @ in the password of dsn
1 parent d37d262 commit 8960223

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

dsn.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type TLSConfig struct {
3232
var (
3333
// Regexp syntax: https://github.com/google/re2/wiki/Syntax
3434
reDSN = regexp.MustCompile(`(.+@)?([^@|^?]+)\\?(.*)`)
35-
reUserPasswd = regexp.MustCompile(`([^:@]+)(:[^:@]+)?@`)
35+
reUserPasswd = regexp.MustCompile(`([^:@]+)(:[^:]+)?@`)
3636
)
3737

3838
const (

dsn_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ func TestParseDSNWithSessionConf(t *testing.T) {
4545
sc["mapreduce_job_quenename"] = "mr"
4646
cfg := &Config{
4747
User: "usr",
48-
Passwd: "pswd",
48+
Passwd: "ps@wd",
4949
Addr: "hiveserver",
5050
DBName: "mydb",
5151
Auth: "PLAIN",
5252
Batch: 200,
5353
SessionCfg: sc,
5454
}
5555
dsn := cfg.FormatDSN()
56-
assert.Equal(t, dsn, "usr:pswd@hiveserver/mydb?batch=200&auth=PLAIN&session.mapreduce_job_quenename=mr")
56+
assert.Equal(t, dsn, "usr:ps@wd@hiveserver/mydb?batch=200&auth=PLAIN&session.mapreduce_job_quenename=mr")
5757

5858
cfg2, e := ParseDSN(dsn)
5959
assert.Nil(t, e)

0 commit comments

Comments
 (0)