Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFixed parse_userinfo breaking with complex passwords #293
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! |
Thomspoon commentedApr 19, 2017
•
edited
Fixed the issue with my last pull request.
The problem with the
parse_userinforight 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 'calledResult::unwrap()on anErrvalue: 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