1
0
mirror of https://github.com/golang/go synced 2024-11-19 05:44:40 -07:00
The Go programming language
Go to file
Mikio Hara dc74f51c43 net: don't enclose non-literal IPv6 addresses in square brackets
The net package uses various textual representations for network
identifiers and locators on the Internet protocol suite as API.
In fact, the representations are the composition of subset of multple
RFCs: RFC 3986, RFC 4007, RFC 4632, RFC 4291 and RFC 5952.

RFC 4007 describes guidelines for the use of textual representation of
IPv6 addressing/routing scope zone and doesn't prohibit the format for
implementation dependent purposes, as in, specifying a literal IPv6
address and its connected region of routing topology as application
user interface. However, a non-literal IPv6 address, for example, a
host name, with a zone enclosed in square brackets confuses us because
a zone is basically for non-global IPv6 addresses and a pair of square
brackets is used as a set of delimiters between a literal IPv6 address
and a service name or transport port number.

To mitigate such confusion, this change makes JoinHostPort not enclose
non-literal IPv6 addresses in square brackets and SplitHostPort accept
the form "host%zone:port" to recommend that anything enclosed in
square brackets should be a literal IPv6 address.

Before this change:
	JoinHostPort("name%zone", "80") = "[name%zone]:80"
	JoinHostPort("[::1%zone]", "80") = "[::1%zone]:80"
	SplitHostPort("name%zone:80") = "", "", "address name%zone:80: missing brackets in address"
	SplitHostPort("[name%zone]:80") = "name%zone", "80", nil
	SplitHostPort("[::1%zone]:80") = "::1%zone", "80", nil

After this change:
	JoinHostPort("name%zone", "80") = "name%zone:80"
	JoinHostPort("[::1%zone]", "80") = "[::1%zone]:80"
	SplitHostPort("name%zone:80") = "name%zone", "80", nil
	SplitHostPort("[name%zone]:80") = "name%zone", "80", nil // for backwards compatibility
	SplitHostPort("[::1%zone]:80") = "::1%zone", "80", nil

Also updates docs and test cases on SplitHostPort and JoinHostPort for
clarification.

Fixes #18059.
Fixes #18060.

Change-Id: I5c3ccce4fa0fbdd58f698fc280635ea4a14d2a37
Reviewed-on: https://go-review.googlesource.com/40510
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-14 08:44:22 +00:00
.github doc: improve issue template and contribution guidelines 2017-02-11 20:42:06 +00:00
api math/big: define Word as uint instead of uintptr 2017-02-21 19:31:40 +00:00
doc spec: clarify size hint for make of maps 2017-04-13 16:15:45 +00:00
lib/time *.bash: always use the same string equality operator 2017-03-14 21:46:31 +00:00
misc cmd/internal/obj: stop storing Text flags in From3 2017-04-12 21:53:39 +00:00
src net: don't enclose non-literal IPv6 addresses in square brackets 2017-04-14 08:44:22 +00:00
test test: disable flaky test/fixedbugs/issue10958.go 2017-04-13 18:28:29 +00:00
.gitattributes
.gitignore cmd/dist: move cmd/go z files to cmd/go/internal/cfg 2017-02-03 20:30:52 +00:00
AUTHORS A+C: automated update 2016-12-21 03:22:22 +00:00
CONTRIBUTING.md doc: improve issue template and contribution guidelines 2017-02-11 20:42:06 +00:00
CONTRIBUTORS A+C: automated update 2016-12-21 03:22:22 +00:00
favicon.ico
LICENSE
PATENTS
README.md readme: add attribution for the Gopher image 2017-02-03 19:39:41 +00:00
robots.txt

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.

Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at https://golang.org/dl/.

After downloading a binary release, visit https://golang.org/doc/install or load doc/install.html in your web browser for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source or load doc/install-source.html in your web browser for source installation instructions.

Contributing

Go is the work of hundreds of contributors. We appreciate your help!

To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html

Note that the Go project does not use GitHub pull requests, and that we use the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.