Skip to content
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: paths parsed with a literal space don't properly stringify in a raw way, losing information #38292

Open
adreed-msft opened this issue Apr 7, 2020 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@adreed-msft
Copy link

adreed-msft commented Apr 7, 2020

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

$ go version
go version go1.13.4 linux/amd64

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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/adele/.cache/go-build"
GOENV="/home/adele/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/adele/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build138708956=/tmp/go-build -gno-record-
gcc-switches"

What did you do?

There are certain cases where maintaining whether a character is encoded or not is of utmost importance (for instance, wildcards when referencing object storage solutions).

If a URL has a space in it when parsed, it will succeed at parsing, but it will choose to return the literal path re-encoded, rather than the raw path. (unexpected behavior)

If a URL is completely safely encoded, it will succeed at parsing, and then it will choose to return the raw path. (expected behavior)

Sample below, demonstrating both cases:
https://play.golang.org/p/IeAIos8Wbx-

What did you expect to see?

I expected the complete raw path when stringifying if it's roughly equivalent (in both cases here, it is roughly equivalent).

What did you see instead?

Instead, I got back a encoded literal path, causing a loss of information.

@andybons
Copy link
Member

andybons commented Apr 7, 2020

@bradfitz @rsc

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 7, 2020
@andybons andybons added this to the Unplanned milestone Apr 7, 2020
@andybons andybons changed the title net/url: Paths parsed with a literal space don't properly stringify in a raw way, losing information net/url: paths parsed with a literal space don't properly stringify in a raw way, losing information Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants