]> Cypherpunks repositories - gostls13.git/commit
net/url: consistently remove ../ elements in JoinPath
authorDamien Neil <dneil@google.com>
Fri, 12 Aug 2022 23:21:09 +0000 (16:21 -0700)
committerDamien Neil <dneil@google.com>
Tue, 23 Aug 2022 22:01:05 +0000 (22:01 +0000)
commit0765da5884adcc8b744979303a36a27092d8fc51
treec47886c37d814284c6b870fff54c33a4dcdb19a5
parent60ad3c48f59c35981dd872ed5dfe74e4d6becab2
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

Fixes #54385.

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>
src/net/url/url.go
src/net/url/url_test.go