Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(postgres): Add URL escaping to database connection string #380

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ test_data
# Go workspace file
.idea
.vscode

# VSCode local history
.history
17 changes: 10 additions & 7 deletions src/lib/config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package config

import "fmt"
import (
"fmt"
"net/url"
)

// this is a pointer so that if someone attempts to use it before loading it will
// panic and force them to load it first.
Expand Down Expand Up @@ -63,12 +66,12 @@ type postgresConfigCommon struct {
func (c postgresConfigCommon) DSN() string {
return fmt.Sprintf(
"postgres://%s:%s@%s:%d/%s?sslmode=disable",
c.User,
c.Password,
c.Host,
c.Port,
c.Database,
)
url.QueryEscape(c.User),
url.QueryEscape(c.Password),
c.Host,
c.Port,
url.QueryEscape(c.Database),
)
}

type carbonConfig struct {
Expand Down
Loading