Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upUnable to pass URL components ('#', '/', '?') in password for DATABASE_URL #871
Comments
killercup
added
bug
help wanted
labels
Apr 25, 2017
jaemk
referenced this issue
Apr 25, 2017
Closed
[bugfix][diesel_cli] parse dbname from connection string in a way that still leaves bugs #861
This comment has been minimized.
|
My opinion is that if you want to parse database connection strings, you should create a separate crate for that functionality instead of using a different grammar that is "kinda close" to what you actually want to parse. Then go into the authoritative C source code of the database drivers and use corrode to transfer the parsing grammar into rust (or do it by hand). edit: after reading the libpq source I can speak authoritatively that for Postgres that
|
This comment has been minimized.
Thomspoon
commented
Apr 27, 2017
•
|
The problem is that the workaround for most other database connectors written in rust is by using percent-encoding, since most are URL based and therefore use the URL parsing standard. The percent-encoding allows you to use your personal password, no matter what it is, without causing errors in the parser for the respective connector. It's as simple as utilizing the percent encoding code already included in the URL crate that is being used for the MySQL portion of the connector. |
This comment has been minimized.
sganz
commented
Apr 28, 2017
•
|
I found this page for PG Has a line in it - I may not be thinking the right way on this but seems it's OK to encode it. Because the characters are not valid (from a specific db perspective) might be another concern. The hope is that all connectors have similar mechanism to encode. Take this all with a grain of salt as I'm new to rust, new to diesel. |
This comment has been minimized.
|
Yes, percent encoding is 100% the correct thing for us to be doing. I actually assumed the URL crate was already decoding where needed for us. It sounds like that's not the case. Either way, having explicit tests to make sure that this is handled seems valuable. |
This comment has been minimized.
|
Also IIRC we've had issues opened before from people unclear that percent encoding was an option. We should try to call it out more loudly in the docs. |
Thomspoon commentedApr 24, 2017
Hello,
Currently, the connection code uses the url crate to parse the connection string. This is fine, however, percent_encoding/decoding is not currently used in the project which leads the user to have to change their passwords if they use the characters '#', '/', or '?'.
For example:
mysql://root:pass#word@localhost:3006/testingwould result in a panic/error.The solution to this is to allow the connection string to be:
mysql://root:pass%23word@localhost:3006/testingand then use the percent_encoding functions to decode the password where it is matched.This seems to be a limitation of the rust-url crate, where I've reached out to the developers, but to no avail. They are just following the url standard.