Skip to content

net/url: Parse returns URL whose Host contains colon #25511

@crvv

Description

@crvv

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

1.10.2 and tip(5776bd5)

Does this issue reproduce with the latest release?

Yes

What did you do?

https://play.golang.org/p/vYNt0qipkxf
Parse an invalid URL, http://socks5h://server

What did you see?

&url.URL{Scheme:"http", Host:"socks5h:", Path:"//server"}

What did you expect to see?

An error.
As per https://tools.ietf.org/html/rfc3986#section-3.2.2, host can't contain :

host        = IP-literal / IPv4address / reg-name
reg-name    = *( unreserved / pct-encoded / sub-delims )
unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
pct-encoded = "%" HEXDIG HEXDIG
reserved    = gen-delims / sub-delims
gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"
sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
            / "*" / "+" / "," / ";" / "="

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions