-
Notifications
You must be signed in to change notification settings - Fork 358
Fixed parse_userinfo breaking with complex passwords #293
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
Conversation
Why shouldn’t it? This code implements the algorithm specified at https://url.spec.whatwg.org/#url-parsing. Interoperability with other implementations is important. If you think the algorithm should be changed, it should be changed in the specification first. The specification’s repository is https://github.com/whatwg/url. When asking for a change, expect to be asked for justification of why this change is desirable and why it won’t break existing content. |
Can you think of an instance where either of those elements would be used in the user_info section of a url? It's obvious they cannot be because if the algorithm is identical, then the algorithm would have a bug. It's not uncommon to have an octothorp in a password, so I don't understand how this isn't more of an issue. |
|
Testing that address with your code throws a panic.
The url In my opinion, the specification at https://url.spec.whatwg.org/#url-parsing is a little ambiguous, and in the relative state section, they should delineate that those flags are looking at the end of a url. They don't say it, but |
Ambiguity is a specification bug that needs to be fixed there. |
Issue created: whatwg/url#294 |
@Thomspoon Why aren't you just passing |
That seems like a workaround, shouldn't be a permanent fix. I don't agree with the result of the issue I created, but I guess I don't have a choice. |
What would |
The From RFC1738:
Doesn't mention anything about the limitations of the password itself. |
This RFC is updated by RFC 3986, but we follow the URL standard anyway. Note that the fact that it doesn't say anything about which characters are allowed or not makes it ambiguous to parse |
Well, the guys over at the URL Standard don't seem to think a retroactive change would be beneficial, so I guess this is a lost cause. I'll just accept the fact that I have to use percent-encoding 🤕 |
Thanks for your contribution anyway! |
Fixed the issue with my last pull request.
The problem with the
parse_userinfo
right now is that it breaks for a fragment delimiter or query string. That's all fine and dandy for further parsing functions, however, this check shouldn't be done with looking for the username and password, because these values can and will be used in passwords.For example:
let url = Url::parse("mysql://root:pass#word@example.com");
Results in:
thread 'main' panicked at 'called
Result::unwrap()on an
Errvalue: InvalidPort'
Due to the early break at the#
sign.After the change, the result is as expected:
mysql://root:pass%23word@example.com/
Unless I'm mistaken, a fragment or query will never appear this early on in a url.
This change is