Skip to content
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

url: parse() fails if the auth field contains a colon(:) or at-sign(@). #2937

Closed
wants to merge 1 commit into from

Conversation

ben-page
Copy link
Contributor

The solution is to add two new fields, username and password. Additionally, url.format() is updated to prefer these new fields over the auth field. The tests and docs have been updated accordingly. This should not be breaking as the behavior of the auth field was not modified.

Here's the issues:
nodejs/node-v0.x-archive#25353
#1802

@mscdex mscdex added the url Issues and PRs related to the legacy built-in url module. label Sep 17, 2015
lib/url.js Outdated
var username, password;
colon = auth.lastIndexOf(':');
if (colon !== -1) {
username = auth.slice(0, colon);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the username has no colons but the password contains one or more colons? What if both of them have colons? FWIW (at least) Chrome 45 and Firefox 40 split on the first colon instead of the last. I think it might be better to follow what browsers are doing so that at least there is some similarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't matter if you split on the first or the last colon, because there should only ever be one. It's invalid to have a non-encoded colon in the username or password. They should be encoded.

That said I agree with the point of doing it like the browsers do, so I'll change it to the first colon.

@ben-page
Copy link
Contributor Author

I depreciated the auth field because none of the major browsers support it and the current implementation can give you a wrong answer. For example:

var url = require('url');

var user = encodeURIComponent('us:er');
var password = encodeURIComponent('pass:word');
var uri = 'http://' + user + ':' + password + '@localhost/';

var parsed = url.parse(uri);
console.log(parsed.auth); // us:er:pass:word

One option is to fix parse so that it contains the encoded username and password separated by a colon, but that could potentially break some applications. I figured it would be better to leave it as is and deprecated it.

@ben-page ben-page changed the title url.parse() fails if the auth field contains a colon(:) or at-sign(@). url: parse() fails if the auth field contains a colon(:) or at-sign(@). Sep 18, 2015
@jasnell
Copy link
Member

jasnell commented Mar 22, 2016

Closing due to lack of any further activity or discussion.

@jasnell jasnell closed this Mar 22, 2016
@ben-page
Copy link
Contributor Author

ben-page commented Apr 7, 2016

@jasnell, there is an open issue associated with this. It was references by another issue just 4 days before you closed this. You and @brendanashworth have confirm that issue as a bug. And you said you would look into it, but I've heard nothing back from you.

Frankly, I'm frustrate with this entire process. It really make be doubt about my decision to use node. How does one get their contributions reviewed? I've re-based the PR three times already. I've brought it to your attention several times. I've received no direction on what's hold this up. From what I can tell it's simply been ignored. This really is a bad way to treat contributors: ignoring them and eventually closing their issues because of "lack of activity".

@MylesBorins MylesBorins self-assigned this Apr 7, 2016
@MylesBorins
Copy link
Contributor

@ben-page I'm sorry that this pr has been left in this state of limbo. Node is maintained by a distributed team and a consensus model. This can allow things to move very quickly, but at the same time can leave things forgotten about.

I'm going to re open this issue and assign it to myself, I'll work with you and the collaborators to figure out what is blocking this from coming in and help get it landed.

Thank you for being patient, contributors like yourself are what make this project awesome!

@MylesBorins MylesBorins reopened this Apr 7, 2016
@MylesBorins
Copy link
Contributor

@ben-page as a start would you be able to rebase one more time? After you do so I'll run both our CI and smoke-tests on this PR and follow up with collaborators to find out what needs to be done next

@jasnell
Copy link
Member

jasnell commented Apr 7, 2016

@ben-page ... given that there had been no activity on this particular PR since september it had appeared as if this particular change request had been abandoned. We do have other efforts underway to look at the same issue (other open PRs and issues) so there appeared (at first) to be little harm in closing the PR because it had appeared to have been abandoned. My apologies for that.

@MylesBorins
Copy link
Contributor

hey @ben-page were you still interested in working on this?

@ben-page
Copy link
Contributor Author

@thealphanerd, yes. Sorry for not getting to this sooner. I rebased. Let me know anything needs be changed.

@MylesBorins
Copy link
Contributor

MylesBorins commented May 10, 2016

@mscdex any thoughts on this?
@nodejs/collaborators are ya'll ok with this change?

ci: https://ci.nodejs.org/job/node-test-pull-request/2565/

@mscdex
Copy link
Contributor

mscdex commented May 10, 2016

Looks like there's at least one url-related test failing. I think the repl-related test failure on plinux is unrelated? EDIT: it looks like the repl test failure is related (it's testing url via the repl).

url.parse() fails if auth portion contains any additional colons. For
example, the auth portion of http://user%40name:pass%3Aword@localhost
is parsed as user@name:pass:word. The solution is to add two new
fields, username and password. Additionally, format(), resolve(), the
doc, and unit tests have been updated reflect the new fields.
@ben-page
Copy link
Contributor Author

ben-page commented May 10, 2016

I screwed up the merge. So, I just redid it. All url tests are passing, now.

@ben-page
Copy link
Contributor Author

@thealphanerd, can the build be restarted?

@MylesBorins
Copy link
Contributor

@ben-page
Copy link
Contributor Author

It looks like it's still failing. When I run the test-url.js manually all tests pass. I'm having some trouble understanding specifically what failed. This is my first time using Jenkins. Can anyone point me in the right direction?

@mscdex
Copy link
Contributor

mscdex commented May 10, 2016

@ben-page I think the doctool test failure is unrelated and is due to another PR that recently got merged

@MylesBorins
Copy link
Contributor

failures are unrelated... a fix is in for the doctool failure. I'll re run the CI once that lands

@MylesBorins
Copy link
Contributor

@MylesBorins
Copy link
Contributor

ci is green... @mscdex thoughts?

@mscdex
Copy link
Contributor

mscdex commented May 16, 2016

@thealphanerd Well, performance-wise encodeField() and a few other places in the (added) code could be improved. I can't really comment on the semantics since I am not familiar enough with various browser behaviors and the specs.

@MylesBorins
Copy link
Contributor

@jasnell do you have any thoughts on this?

@jasnell
Copy link
Member

jasnell commented Jun 6, 2016

Yes, this is one of the issue I'm going to try to fix by introducing the WHATWG URL parsing support (nodejs/node-eps#28). There are several of these kinds of issues that are caused by our parser being less-than-compliant with the spec.

* `auth`: The authentication information portion of a URL.

Example: `'user:pass'`
Deprecated: `auth` does not handled URL encoding properly, use `username` and `password` instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "handled" -> "handle"

@jasnell jasnell added the stalled Issues and PRs that are stalled. label Jul 3, 2016
@rvagg rvagg force-pushed the master branch 2 times, most recently from c133999 to 83c7a88 Compare October 18, 2016 17:01
@MylesBorins
Copy link
Contributor

@jasnell is this still relevant?

@jasnell
Copy link
Member

jasnell commented Dec 29, 2016

This is not an issue with the new WHATWG URL parser but it still exists with the old url.parse() implementation. I have no plans to update that implementation to fix the issue, however.

@jasnell
Copy link
Member

jasnell commented Feb 28, 2017

Closing due to lack of forward progress on this. As indicated, this is not an issue with the new URL parser

@jasnell jasnell closed this Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stalled Issues and PRs that are stalled. url Issues and PRs related to the legacy built-in url module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants