-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Escape SQL username and password parameters before substituting them into a URL #7089
Conversation
// Connection() uses sql.Open uses lib/pq uses net/url.Parse | ||
u, err := url.Parse(sql.ConnectionURL) | ||
if err != nil { | ||
t.Errorf("URL parse error on %q %q: %+v", tc.Username, tc.Password, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change these to t.Fatalf()
to fail fast?
Whoops didn't refresh after Jeff merged.. |
{"postgres", "pass/word"}, | ||
{"postgres", "p@ssword"}, | ||
{"postgres", "pass\"word\""}, | ||
// Much to my surprise, CREATE USER "{{password}}" PASSWORD 'foo' worked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PG treats anything quoted as a literal and literals can be used for roles and database names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Customer reported an issue where they could not use "password{0}" as a password in a Postgres connection.