-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
net/url: mysql://boulder@tcp(localhost:3306)/foo no longer parses #12023
Comments
Is that even a valid URL? The RFC described the authority component like this:
So I don't think there can be parens that span the host and port section. |
I have a similar issue with MongoDB URIs.
Now, when re-encoding into string, I get the As far as I understand the code for 'encodeHost' was added as part of commit 8e95654. The decision in the commit was to allow only reserved characters to be unencoded. The sub-delimiters that could be left unescaped (including commas and parenthesis) were chosen to be escaped. This choice is what is causing issues for us. |
I'm totally fine hearing this was a bug fix and having this bug get closed. If that happens, as a user, I'd love for the database/sql driver maintainers to get some heads up. I'm currently in a bit of a discussion with one for the mysql driver about this in that other ticket. They were surprised by the change in behavior, but, unfortunately, more surprised by their users wanting to control and modify the strings before they go in. I think the postgres folks are more familiar with their users using and working with db strings (including heroku's DATABASE env variable stuff, etc), but some of the mysql folks are, uh, not so clear they want to support this use case. There might be more issues like we're seeing from monogodb and mysql and a little bit of foreknowledge might make driver devs amenable to changes in their APIs to accommodate their users or maybe just some documentation on really solid workarounds. |
The fix for all of these issues is not to use a URL parsing routine for URL-like DSNs that are not actually URLs. |
Right, I was hoping the mysql and other folks would give us a nice way to use an actual URL instead of a DSN. Something like a mysqltcp:// scheme and such. Thanks for your interest! |
In terms of RFC 3986,
but
Looks like it would be a bit hard to support various database source names, connection strings. |
|
Couple of comments on this thread:
Your broader comment about RFC 3986 and it's suitability to a wide range of connection strings is understandable. However, it is common to use URIs as connection strings. I have managed to do so for connecting to several services (redis, cassandra, mongodb, ceph/rados), without using the invalid forms you posted above. Bottom line is: as a user, I would much rather make an effort to make sure my URIs are complaint with RFC 3986, and be able to rely on net/url to do URI manipulation rather than to design custom connection string parsers, which are likely 99% similar to net/url. In any case, whichever way the Go team decides, I think a note is warranted in the release notes. There may be others, like me, who have strived to keep URIs RFC compliant, who will have broken code when upgrading from Go <= 1.4.2 to 1.5. |
Please open a new issue for escaping host subcomponent of URL. |
@liviosoares I created #12036 for your mongodb issue. I have some questions there for you. Thanks. |
@liviosoares I agree that it's nice to use URIs to specify DSNs, but if your database/driver does that, it should support URI semantics:
If these semantics don't hold for these DSNs, then such strings are not URIs but are merely URI-like, and |
Mikioh, please see my question on #12036 about host encoding. |
The code breaking this URL seems to me a classic example of fuzz testing hurting instead of helping, by inducing real bugs when we fix hypothetical bugs. I am inclined to move the validHostPort check up into the [ipv6]:port syntax case. I don't see any reason for it to be here. It is not relevant to the original fuzz report (#11208).
|
CL https://golang.org/cl/13253 mentions this issue. |
The URL
mysql://boulder@tcp(localhost:3306)/boulder_test?parseTime=true
would parse and re-encode correctly in go 1.4.2.However, in 1.5.0-beta3,
url.Parse("mysql://boulder@tcp(localhost:3306)/boulder_test?parseTime=true")
now returns the error message:This was found in go-sql-driver/mysql#362.
The text was updated successfully, but these errors were encountered: