-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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 not working correctly for a non absolute URL with port. #22955
Comments
Dup of #21415 That is not a valid URL. An absolute URL starts with a scheme (http://, etc) and a relative URL must never contain a colon in its first path element, per the specs. |
@bradfitz Shouldn't Parse return an error in that case? |
Just keep in mind that you're parsing either a full URL or just a path. Other crap tends to end up in Path or Opaque (https://play.golang.org/p/vbQkLpYwRX) if it's malformed and not one of those forms, but don't depend on how malformed stuff gets parsed. |
Change https://golang.org/cl/81436 mentions this issue: |
That Parse doesn't parse ("foo.com/path" or "foo.com:443/path") has become something of a FAQ. Updates #19779 Updates #21415 Updates #22955 Change-Id: Ib68efddb67f59b1374e8ed94effd4a326988dee7 Reviewed-on: https://go-review.googlesource.com/81436 Reviewed-by: Ian Lance Taylor <iant@golang.org>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes: https://play.golang.org/p/yoLxXnHE1J
What operating system and processor architecture are you using (
go env
)?What did you do?
url.Parse
not working for relative url with port.When parsing www.example.com:443, IsAbs returns true, and port is empty.
https://play.golang.org/p/yoLxXnHE1J
What did you expect to see?
IsAbs
returnsfalse.
What did you see instead?
IsAbs
returnstrue
.The text was updated successfully, but these errors were encountered: