]> Cypherpunks repositories - gostls13.git/commit
net/url: prefix relative paths containing ":" in the first segment with "./"
authorKale Blankenship <kale@lemnisys.com>
Thu, 22 Sep 2016 02:03:06 +0000 (19:03 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 22 Sep 2016 18:26:26 +0000 (18:26 +0000)
commitad5d91c17a3c0bc4acf9e4036b050517972432f0
tree72b5c8bf28a674859b4adf5dae044b35a0fcd025
parentcddddbc6231177c87b72f95209ab51abb74bcbc5
net/url: prefix relative paths containing ":" in the first segment with "./"

This change modifies URL.String to prepend "./" to a relative URL which
contains a colon in the first path segment.

Per RFC 3986 ยง4.2:

> A path segment that contains a colon character (e.g., "this:that")
> cannot be used as the first segment of a relative-path reference, as
> it would be mistaken for a scheme name.  Such a segment must be
> preceded by a dot-segment (e.g., "./this:that") to make a relative-
> path reference.

https://go-review.googlesource.com/27440 corrects the behavior for http.FileServer,
but URL.String will still return an invalid URL. This CL reverts the changes to
http.FileServer as they are unnecessary with this fix.

Fixes #17184

Change-Id: I9211ae20f82c91b785d1b079b2cd766487d94225
Reviewed-on: https://go-review.googlesource.com/29610
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/net/http/fs.go
src/net/http/fs_test.go
src/net/url/url.go
src/net/url/url_test.go