mattes / migrate

Database migrations. CLI and Golang library.
Other
2.29k stars 326 forks source link

prevent net/url encoding the user password #324

Open RyanDeng opened 6 years ago

RyanDeng commented 6 years ago

According to net/url

// A URL represents a parsed URL (technically, a URI reference).
//
// The general form represented is:
//
//  [scheme:][//[userinfo@]host][/]path[?query][#fragment]
//
// URLs that do not start with a slash after the scheme are interpreted as:
//
//  scheme:opaque[?query][#fragment]
//

If the url starts with a slash after the scheme, the url.String() func will do url encode for the userinfo. In this case, password that has non-alphanumeric char will be url encoded and mysql auth will fail.

Probably the best fix should be in Open() func of database/driver.go. However I'm using mysql and not familiar with other drivers, so make a tiny fix in the mysql driver