[go] net/url: escape // at start of Path when OmitHost set

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
11:29 AM (12 hours ago) 11:29 AM
to Damien Neil, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Alan Donovan, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

1 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: src/net/url/url.go
Insertions: 3, Deletions: 0.

@@ -841,6 +841,9 @@
}
path := u.EscapedPath()
if u.OmitHost && u.Host == "" && u.User == nil && strings.HasPrefix(path, "//") {
+ // Escape the first / in a path starting with "//" and no authority
+ // so that re-parsing the URL doesn't turn the path into an authority
+ // (e.g., Path="//host/p" producing "http://host/p").
buf.WriteString("%2F")
path = path[1:]
}
```

Change information

Commit message:
net/url: escape // at start of Path when OmitHost set

When a URL has OmitHost set and a Path starting with //,
escape the first / in the path to avoid emitting a URL
with the host set from the Path.

For example for

u := url.URL{Scheme: "file", OmitHost: true, Path: "//host/path"}

u.String is now "file:%2F/host/path", not "file://host/path".

Fixes #78328
Change-Id: I017af26724cc55f8b7e6f7c969f1495b6a6a6964
Auto-Submit: Damien Neil <dn...@google.com>
Reviewed-by: Alan Donovan <adon...@google.com>
Files:
  • M src/net/url/url.go
  • M src/net/url/url_test.go
Change size: S
Delta: 2 files changed, 32 insertions(+), 5 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Alan Donovan
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I017af26724cc55f8b7e6f7c969f1495b6a6a6964
Gerrit-Change-Number: 758881
Gerrit-PatchSet: 3
Gerrit-Owner: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages