]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.19] net/url: consistently remove ../ elements in JoinPath
authorDamien Neil <dneil@google.com>
Fri, 12 Aug 2022 23:21:09 +0000 (16:21 -0700)
committerHeschi Kreinick <heschi@google.com>
Mon, 29 Aug 2022 19:13:49 +0000 (19:13 +0000)
commit28335508913a46e05ef0c04a18e8a1a6beb775ec
tree1e22430b8e4185751d1285421ec57017cf0dab83
parentd2bcb22ce07ffbbdefe1370dec597b35d8d58e81
[release-branch.go1.19] net/url: consistently remove ../ elements in JoinPath

JoinPath would fail to remove relative elements from the start of
the path when the first path element is "".

In addition, JoinPath would return the original path unmodified
when provided with no elements to join, violating the documented
behavior of always cleaning the resulting path.

Correct both these cases.

    JoinPath("http://go.dev", "../go")
    // before: http://go.dev/../go
    // after:  http://go.dev/go

    JoinPath("http://go.dev/../go")
    // before: http://go.dev/../go
    // after:  http://go.dev/go

For #54385.
Fixes #54635.
Fixes CVE-2022-32190.

Change-Id: I6d22cd160d097c50703dd96e4f453c6c118fd5d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/423514
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
(cherry picked from commit 0765da5884adcc8b744979303a36a27092d8fc51)
Reviewed-on: https://go-review.googlesource.com/c/go/+/425357
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/net/url/url.go
src/net/url/url_test.go