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

net/url: Parse does not parse username and password correctly #3439

Closed
snaury opened this issue Mar 30, 2012 · 6 comments
Closed

net/url: Parse does not parse username and password correctly #3439

snaury opened this issue Mar 30, 2012 · 6 comments

Comments

@snaury
Copy link
Contributor

snaury commented Mar 30, 2012

If you do something like:

u, _ := url.Parse("http://user@gmail.com:password@hostname.com:80/path";)

Then u.User.Username() would be "user" and u.Host would be
"gmail.com:password@hostname.com:80". This is unexpected and contrary to other
languages and frameworks. Instead of splitting on the first "@" in authority,
url.Parse should split on the last.
@gopherbot
Copy link

Comment 1 by stephen@q5comm.com:

I submitted a CL.
http://golang.org/cl/5975050/

@remyoudompheng
Copy link
Contributor

Comment 2:

See RFC3986, section 3.2.1 for the expected format and section 2.3 for the list of
unreserved characters. Your URL is invalid.
By the way, to submit a CL, you should send it on the mailing-lint by running "hg mail"
as explained on http://golang.org/doc/contribute.html Otherwise it's invisible.

@snaury
Copy link
Contributor Author

snaury commented Mar 31, 2012

Comment 3:

I know it's technically invalid, still that's what lots of url parsers too. One big
example is Google Chrome, which makes request to hostname.com/path, and not something
else. I would be ok if url.Parse returned an error in a case like that, btw. It's just
splitting on the last "@" in authority is a lot easier.

@dsymonds
Copy link
Contributor

dsymonds commented Apr 4, 2012

Comment 4:

Yes, I think net/url should either clearly reject that URL, or parse it like other URL
parsers.
Full example: http://play.golang.org/p/ijPqsLnvtl

Labels changed: added priority-soon, packagebug, removed priority-triage.

Status changed to Accepted.

@snaury
Copy link
Contributor Author

snaury commented May 20, 2012

Comment 5:

I submitted a new CL at http://golang.org/cl/6206090, since a small change
requested by rsc was not done by stephen for 1.5 months already.

@rsc
Copy link
Contributor

rsc commented May 22, 2012

Comment 6:

This issue was closed by revision f7277da.

Status changed to Fixed.

rsc pushed a commit that referenced this issue May 11, 2015
… authority

««« backport 89a9ef95c8db
net/url: better parsing of urls with @ symbol in authority

Fixes #3439

R=r, rsc, dsymonds, n13m3y3r
CC=golang-dev
https://golang.org/cl/6206090

»»»
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants