You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to how the dsn decoding is done any username with a ':' fails. We have a system at my job where ':' are required.
Since there is no url.QueryUnescape() on the username adding the proper escapes, like standard based URI, doesn't work. It will either be treated as a password incorrectly or the escaped value will be never unescaped and so the user will fail.
Adding a url.QueryUnescape into dsn.go fixes the issue for me.
Example code
// unescaped treats it like a password (which is ok)
db.Open('mysql', "foo:bar@tcp(localhost)")
// escaped should work
db.Open('mysql', "foo%3Abar@tcp(localhost)")
The text was updated successfully, but these errors were encountered:
That is super unfortunate. Changing username is not an option. Forking i guess it is.
Ever consider using url.Parse and looking for a u.Schema of 'mysql'. If the URL cannot be parsed or the schema is missing fall back to the old parsing. If it is there then use a better form of parsing.
Postgres's go driver does something like this.
liuxinbot
pushed a commit
to liuxinbot/mysql
that referenced
this issue
Jan 17, 2023
Sometimes usernames may have characters that need encoding such as : or
@. This fixes the problem by url escaping the username on FormatDSN and
unescaping it on ParseDSN.
Although the DSNs are not proper URIs escaping of username is defined in
https://www.ietf.org/rfc/rfc3986.txtFixes: go-sql-driver#688
Issue description
Due to how the dsn decoding is done any username with a ':' fails. We have a system at my job where ':' are required.
Since there is no url.QueryUnescape() on the username adding the proper escapes, like standard based URI, doesn't work. It will either be treated as a password incorrectly or the escaped value will be never unescaped and so the user will fail.
Adding a url.QueryUnescape into dsn.go fixes the issue for me.
Example code
The text was updated successfully, but these errors were encountered: