Skip to content

net/url: should Parse accept hostnames with leading hyphens? #19462

@xeoncross

Description

@xeoncross

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

go version go1.7.4 darwin/amd64

What did you do?

I have tested with multiple invalid strings and found that url.Parse() and url.ParseRequestURI() allow invalid URL strings without an error.

u, err := url.Parse("http://-10:10/foobar")

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

What did you expect to see?

An Error. -10:10 is not a URL, an IP 4/6, or a CIDR.

What did you see instead?

net/url allows invalid hostnames

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions