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: Parsing malformed URL does not result in error #19110

Closed
lewisporter opened this issue Feb 15, 2017 · 4 comments
Closed

net/url: Parsing malformed URL does not result in error #19110

lewisporter opened this issue Feb 15, 2017 · 4 comments

Comments

@lewisporter
Copy link

lewisporter commented Feb 15, 2017

What version of Go are you using (go version)?

go version go1.7.5 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

What did you do?

https://play.golang.org/p/qcpF1Vz3sY

What did you expect to see?

I expected the call to url.Parse() to raise an error. Otherwise, I would expect testURL.Query() to return an error, if the function signature allowed it.

What did you see instead?

testURL.Query() silently drops malformed query parameters and url.Parse() raises no error.

@bradfitz
Copy link
Contributor

I'm pretty sure this is working as intended.

The format of a URL is more permissive than the conventional formatting of key=value&key=value query args.

@lewisporter
Copy link
Author

@bradfitz That makes sense - but then, shouldn't testURL.Query() be able to raise an error?

@bradfitz
Copy link
Contributor

Looks intentional:

func (u *URL) Query() Values {
	v, _ := ParseQuery(u.RawQuery)
	return v
}

And we can't change the signature at this point due to go1compat.

I suppose we could add a couple words of documentation to that method.

@bradfitz bradfitz added this to the Go1.9Maybe milestone Feb 15, 2017
@gopherbot
Copy link

CL https://golang.org/cl/37194 mentions this issue.

@golang golang locked and limited conversation to collaborators Feb 18, 2018
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

3 participants