Description
What version of Go are you using (go version
)?
$ go version 1.17.1
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env ➜ ~ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/chrisg/.cache/go-build" GOENV="/home/chrisg/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/chrisg/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/chrisg" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/chrisg/sdk/go1.17.1" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/chrisg/sdk/go1.17.1/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.17.1" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/dev/null" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build237025076=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Parsed a url with a non url-encoded semicolon in a value of a query string parameter
https://go.dev/play/p/n68WBqiRmkt
u, err := url.Parse("http://foo.com/?bar=;&baz=foobar&abc&xyz=&ikj=n;m")
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", u)
fmt.Printf("%+v\n", u.Query())
fmt.Printf("%+v\n", u.RawQuery)
q, err := url.ParseQuery(u.RawQuery)
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", q)
What did you expect to see?
The value parsed literally, and successfully - e.g.,
map[abc:[] baz:[foobar] xyz:[] bar:[;] ikj=n;m]
What did you see instead?
http://foo.com/?bar=;&baz=foobar&abc&xyz=&ikj=n;m
map[abc:[] baz:[foobar] xyz:[]]
bar=;&baz=foobar&abc&xyz=&ikj=n;m
panic: invalid semicolon separator in query
goroutine 1 [running]:
main.main()
/tmp/sandbox883685007/prog.go:22 +0x1eb
Program exited.
There have been a number of issues related to the new semicolon handling (some of which raised by myself):
- Issues parsing urls containing semicolons #49683 (closed as a duplicate of proposal: net/url: provide AllowQuerySemicolons functionality for net/url rather than net/http #47425 -- I don't believe it is)
- net/http: remove semicolon warning #49399
- proposal: net/url: provide AllowQuerySemicolons functionality for net/url rather than net/http #47425
The original issue, and proposal to add AllowQuerySemicolons
:
- net/url: don't parse ';' as a separator in query string [freeze exception] #25192
- net/http: add AllowQuerySemicolons [freeze exception] #45973
It's not clear why the current behavior has been chosen. The oringal issue only highlighted semicolons as an issue as a seperator. The current implementation ignores them entirely -- which is incredibly frustrating.
The fact of the matter is that urls containing raw semicolons do exist and those parameter values have meaning.
I'd really appreciate if we could have a dialog about potential options. I'm willing to invest time to do any implementation, but it's not clear to me what the powers that be will find acceptable.
As it stands, the issues introduced by the url parsing change in 1.17 has prevented upgrades at my org. I'd really like to help find a safe & viable way forward